AliPhysics  vAN-20150822 (d56cf94)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliAnalysisTaskSEXic2eleXifromAODtracks.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appeuear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
18 //
19 //
20 // Xic->eXi analysis code
21 //
22 // Input: AOD
23 // Output: TTree or THnSparse (mass vs pT vs Centrality)
24 //
25 //-------------------------------------------------------------------------
26 //
27 // Authors: Y.S Watanabe(a)
28 // (a) CNS, the University of Tokyo
29 // Contatcs: wyosuke@cns.s.u-tokyo.ac.jp
30 //-------------------------------------------------------------------------
31 
32 #include <TSystem.h>
33 #include <TParticle.h>
34 #include <TParticlePDG.h>
35 #include <TH1F.h>
36 #include <TH1F.h>
37 #include <TH2F.h>
38 #include <THnSparse.h>
39 #include <TLorentzVector.h>
40 #include <TTree.h>
41 #include "TROOT.h"
42 #include <TDatabasePDG.h>
43 #include <AliAnalysisDataSlot.h>
44 #include <AliAnalysisDataContainer.h>
45 #include "AliStack.h"
46 #include "AliMCEvent.h"
47 #include "AliAnalysisManager.h"
48 #include "AliAODMCHeader.h"
49 #include "AliAODHandler.h"
50 #include "AliLog.h"
51 #include "AliExternalTrackParam.h"
52 #include "AliAODVertex.h"
53 #include "AliESDVertex.h"
54 #include "AliAODRecoDecay.h"
55 #include "AliAODRecoDecayHF.h"
56 #include "AliAODRecoCascadeHF.h"
57 #include "AliESDtrack.h"
58 #include "AliAODTrack.h"
59 #include "AliAODv0.h"
60 #include "AliAODcascade.h"
61 #include "AliAODMCParticle.h"
62 #include "AliAnalysisTaskSE.h"
64 #include "AliPIDResponse.h"
65 #include "AliPIDCombined.h"
66 #include "AliTOFPIDResponse.h"
67 #include "AliAODPidHF.h"
68 #include "AliInputEventHandler.h"
69 #include "AliESDtrackCuts.h"
70 #include "AliNeutralTrackParam.h"
71 #include "AliKFParticle.h"
72 #include "AliKFVertex.h"
73 #include "AliExternalTrackParam.h"
74 #include "AliESDtrack.h"
75 #include "AliCentrality.h"
76 #include "AliVertexerTracks.h"
77 #include "AliEventPoolManager.h"
79 
80 using std::cout;
81 using std::endl;
82 
86 
87 //__________________________________________________________________________
89  AliAnalysisTaskSE(),
90  fUseMCInfo(kFALSE),
91  fOutput(0),
92  fOutputAll(0),
93  fListCuts(0),
94  fCEvents(0),
95  fHTrigger(0),
96  fHCentrality(0),
97  fAnalCuts(0),
98  fIsEventSelected(kFALSE),
99  fWriteVariableTree(kFALSE),
100  fWriteEachVariableTree(kFALSE),
101  fWriteMCVariableTree(kFALSE),
102  fVariablesTree(0),
103  fEleVariablesTree(0),
104  fCascVariablesTree(0),
105  fMCVariablesTree(0),
106  fMCEleVariablesTree(0),
107  fMCCascVariablesTree(0),
108  fReconstructPrimVert(kFALSE),
109  fIsMB(kFALSE),
110  fIsSemi(kFALSE),
111  fIsCent(kFALSE),
112  fIsINT7(kFALSE),
113  fIsEMC7(kFALSE),
114  fCandidateVariables(),
115  fCandidateEleVariables(),
116  fCandidateCascVariables(),
117  fCandidateMCVariables(),
118  fCandidateMCEleVariables(),
119  fCandidateMCCascVariables(),
120  fVtx1(0),
121  fV1(0),
122  fVtxZ(0),
123  fBzkG(0),
124  fCentrality(0),
125  fRunNumber(0),
126  fTriggerCheck(0),
127  fUseCentralityV0M(kFALSE),
128  fEvNumberCounter(0),
129  fHistoEleXiMass(0),
130  fHistoEleXiMassRS(0),
131  fHistoEleXiMassWS(0),
132  fHistoEleXiMassRSMix(0),
133  fHistoEleXiMassWSMix(0),
134  fHistoEleXiMassvsElePtRS(0),
135  fHistoEleXiMassvsElePtWS(0),
136  fHistoEleXiMassvsElePtRSMix(0),
137  fHistoEleXiMassvsElePtWSMix(0),
138  fHistoElePtRS(0),
139  fHistoElePtWS(0),
140  fHistoElePtRSMix(0),
141  fHistoElePtWSMix(0),
142  fHistoEleXiMassMCS(0),
143  fHistoEleXiMassMCGen(0),
144  fHistoEleXiMassvsElePtMCS(0),
145  fHistoEleXiMassvsElePtMCGen(0),
146  fHistoElePtMCS(0),
147  fHistoElePtMCGen(0),
148  fHistoElePtvsEtaRS(0),
149  fHistoElePtvsEtaWS(0),
150  fHistoElePtvsEtaRSMix(0),
151  fHistoElePtvsEtaWSMix(0),
152  fHistoElePtvsEtaMCS(0),
153  fHistoElePtvsEtaMCGen(0),
154  fHistoElePtvsXiPtRS(0),
155  fHistoElePtvsXiPtWS(0),
156  fHistoElePtvsXiPtRSMix(0),
157  fHistoElePtvsXiPtWSMix(0),
158  fHistoElePtvsXiPtMCS(0),
159  fHistoElePtvsXiPtvsXicPtMCS(0),
160  fHistoElePtvsXiPtMCGen(0),
161  fHistoElePtvsXiPtvsXicPtMCGen(0),
162  fHistoElePtvsXiPtMCXicGen(0),
163  fHistoElePtvsd0RS(0),
164  fHistoElePtvsd0WS(0),
165  fHistoElePtvsd0RSMix(0),
166  fHistoElePtvsd0WSMix(0),
167  fHistoElePtvsd0MCS(0),
168  fHistoElePtvsd0PromptMCS(0),
169  fHistoElePtvsd0BFeeddownMCS(0),
170  fHistoBachPt(0),
171  fHistoBachPtMCS(0),
172  fHistoBachPtMCGen(0),
173  fHistod0Bach(0),
174  fHistoXiMassvsPt(0),
175  fHistoXiMassvsPtMCS(0),
176  fHistoXiMassvsPtMCGen(0),
177  fHistoOmegaMassvsPt(0),
178  fHistoElectronTPCPID(0),
179  fHistoElectronTOFPID(0),
180  fHistoElectronTPCSelPID(0),
181  fHistoElectronTOFSelPID(0),
182  fHistoElectronTPCPIDSelTOF(0),
183  fHistoElectronTPCPIDSelTOFSmallEta(0),
184  fHistoElectronTPCPIDSelTOFLargeEta(0),
185  fHistoElectronQovPtvsPhi(0),
186  fHistoXiQovPtvsPhi(0),
187  fHistoXicMCGen(0),
188  fHistoXicElectronMCGen(0),
189  fHistoElectronMCGen(0),
190  fHistoXiMCGen(0),
191  fCounter(0),
192  fHistonEvtvsRunNumber(0),
193  fHistonElevsRunNumber(0),
194  fHistonXivsRunNumber(0),
195  fDoEventMixing(0),
196  fNumberOfEventsForMixing (5),
197  fNzVtxBins (0),
198  fNCentBins (0),
199  fNOfPools(1),
200  fEventBuffer(0x0),
201  fEventInfo(0x0),
202  fElectronTracks(0x0)
203 {
204  //
205  // Default Constructor.
206  //
207  for(Int_t i=0;i<23;i++){
208  fHistoElePtvsCutVarsRS[i] = 0;
209  fHistoElePtvsCutVarsWS[i] = 0;
211  }
212  for(Int_t i=0;i<8;i++){
214  }
215 }
216 
217 //___________________________________________________________________________
220  Bool_t writeVariableTree) :
221  AliAnalysisTaskSE(name),
222  fUseMCInfo(kFALSE),
223  fOutput(0),
224  fOutputAll(0),
225  fListCuts(0),
226  fCEvents(0),
227  fHTrigger(0),
228  fHCentrality(0),
229  fAnalCuts(analCuts),
230  fIsEventSelected(kFALSE),
231  fWriteVariableTree(writeVariableTree),
232  fWriteEachVariableTree(kFALSE),
233  fWriteMCVariableTree(kFALSE),
234  fVariablesTree(0),
235  fEleVariablesTree(0),
236  fCascVariablesTree(0),
237  fMCVariablesTree(0),
238  fMCEleVariablesTree(0),
239  fMCCascVariablesTree(0),
240  fReconstructPrimVert(kFALSE),
241  fIsMB(kFALSE),
242  fIsSemi(kFALSE),
243  fIsCent(kFALSE),
244  fIsINT7(kFALSE),
245  fIsEMC7(kFALSE),
246  fCandidateVariables(),
247  fCandidateEleVariables(),
248  fCandidateCascVariables(),
249  fCandidateMCVariables(),
250  fCandidateMCEleVariables(),
251  fCandidateMCCascVariables(),
252  fVtx1(0),
253  fV1(0),
254  fVtxZ(0),
255  fBzkG(0),
256  fCentrality(0),
257  fRunNumber(0),
258  fTriggerCheck(0),
259  fUseCentralityV0M(kFALSE),
260  fEvNumberCounter(0),
261  fHistoEleXiMass(0),
262  fHistoEleXiMassRS(0),
263  fHistoEleXiMassWS(0),
264  fHistoEleXiMassRSMix(0),
265  fHistoEleXiMassWSMix(0),
266  fHistoEleXiMassvsElePtRS(0),
267  fHistoEleXiMassvsElePtWS(0),
268  fHistoEleXiMassvsElePtRSMix(0),
269  fHistoEleXiMassvsElePtWSMix(0),
270  fHistoElePtRS(0),
271  fHistoElePtWS(0),
272  fHistoElePtRSMix(0),
273  fHistoElePtWSMix(0),
274  fHistoEleXiMassMCS(0),
275  fHistoEleXiMassMCGen(0),
276  fHistoEleXiMassvsElePtMCS(0),
277  fHistoEleXiMassvsElePtMCGen(0),
278  fHistoElePtMCS(0),
279  fHistoElePtMCGen(0),
280  fHistoElePtvsEtaRS(0),
281  fHistoElePtvsEtaWS(0),
282  fHistoElePtvsEtaRSMix(0),
283  fHistoElePtvsEtaWSMix(0),
284  fHistoElePtvsEtaMCS(0),
285  fHistoElePtvsEtaMCGen(0),
286  fHistoElePtvsXiPtRS(0),
287  fHistoElePtvsXiPtWS(0),
288  fHistoElePtvsXiPtRSMix(0),
289  fHistoElePtvsXiPtWSMix(0),
290  fHistoElePtvsXiPtMCS(0),
291  fHistoElePtvsXiPtvsXicPtMCS(0),
292  fHistoElePtvsXiPtMCGen(0),
293  fHistoElePtvsXiPtvsXicPtMCGen(0),
294  fHistoElePtvsXiPtMCXicGen(0),
295  fHistoElePtvsd0RS(0),
296  fHistoElePtvsd0WS(0),
297  fHistoElePtvsd0RSMix(0),
298  fHistoElePtvsd0WSMix(0),
299  fHistoElePtvsd0MCS(0),
300  fHistoElePtvsd0PromptMCS(0),
301  fHistoElePtvsd0BFeeddownMCS(0),
302  fHistoBachPt(0),
303  fHistoBachPtMCS(0),
304  fHistoBachPtMCGen(0),
305  fHistod0Bach(0),
306  fHistoXiMassvsPt(0),
307  fHistoXiMassvsPtMCS(0),
308  fHistoXiMassvsPtMCGen(0),
309  fHistoOmegaMassvsPt(0),
310  fHistoElectronTPCPID(0),
311  fHistoElectronTOFPID(0),
312  fHistoElectronTPCSelPID(0),
313  fHistoElectronTOFSelPID(0),
314  fHistoElectronTPCPIDSelTOF(0),
315  fHistoElectronTPCPIDSelTOFSmallEta(0),
316  fHistoElectronTPCPIDSelTOFLargeEta(0),
317  fHistoElectronQovPtvsPhi(0),
318  fHistoXiQovPtvsPhi(0),
319  fHistoXicMCGen(0),
320  fHistoXicElectronMCGen(0),
321  fHistoElectronMCGen(0),
322  fHistoXiMCGen(0),
323  fCounter(0),
324  fHistonEvtvsRunNumber(0),
325  fHistonElevsRunNumber(0),
326  fHistonXivsRunNumber(0),
327  fDoEventMixing(0),
328  fNumberOfEventsForMixing (5),
329  fNzVtxBins (0),
330  fNCentBins (0),
331  fNOfPools(1),
332  fEventBuffer(0x0),
333  fEventInfo(0x0),
334  fElectronTracks(0x0)
335 {
336  //
337  // Constructor. Initialization of Inputs and Outputs
338  //
339  Info("AliAnalysisTaskSEXic2eleXifromAODtracks","Calling Constructor");
340 
341  for(Int_t i=0;i<23;i++){
342  fHistoElePtvsCutVarsRS[i] = 0;
343  fHistoElePtvsCutVarsWS[i] = 0;
345  }
346  for(Int_t i=0;i<8;i++){
348  }
349 
350  DefineOutput(1,TList::Class()); //conters
351  DefineOutput(2,TList::Class());
352  DefineOutput(3,TList::Class()); //conters
353  DefineOutput(4,TTree::Class()); //My private output
354  DefineOutput(5,TTree::Class()); //My private output
355  DefineOutput(6,TTree::Class()); //My private output
356  DefineOutput(7,TTree::Class()); //My private output
357  DefineOutput(8,AliNormalizationCounter::Class());
358  DefineOutput(9,TTree::Class()); //My private output
359  DefineOutput(10,TTree::Class()); //My private output
360 }
361 
362 //___________________________________________________________________________
364  //
365  // destructor
366  //
367  Info("~AliAnalysisTaskSEXic2eleXifromAODtracks","Calling Destructor");
368 
369  if (fOutput) {
370  delete fOutput;
371  fOutput = 0;
372  }
373 
374  if (fOutputAll) {
375  delete fOutputAll;
376  fOutputAll = 0;
377  }
378 
379  if (fListCuts) {
380  delete fListCuts;
381  fListCuts = 0;
382  }
383 
384 
385  if (fAnalCuts) {
386  delete fAnalCuts;
387  fAnalCuts = 0;
388  }
389 
390  if (fVariablesTree) {
391  delete fVariablesTree;
392  fVariablesTree = 0;
393  }
394  if (fEleVariablesTree) {
395  delete fEleVariablesTree;
396  fEleVariablesTree = 0;
397  }
398  if (fCascVariablesTree) {
399  delete fCascVariablesTree;
400  fCascVariablesTree = 0;
401  }
402  if (fMCVariablesTree) {
403  delete fMCVariablesTree;
404  fMCVariablesTree = 0;
405  }
406  if (fMCEleVariablesTree) {
407  delete fMCEleVariablesTree;
409  }
410  if (fMCCascVariablesTree) {
411  delete fMCCascVariablesTree;
413  }
414  if(fCounter){
415  delete fCounter;
416  fCounter = 0;
417  }
418 }
419 
420 //_________________________________________________
422  //
423  // Initialization
424  //
425  //
426 
427  fIsEventSelected=kFALSE;
428 
429  if (fDebug > 1) AliInfo("Init");
430 
431  fListCuts = new TList();
432  fListCuts->SetOwner();
433  fListCuts->SetName("ListCuts");
435  PostData(2,fListCuts);
436 
437  return;
438 }
439 
440 //_________________________________________________
442 {
443  //
444  // UserExec
445  //
446 
447  if (!fInputEvent) {
448  AliError("NO EVENT FOUND!");
449  return;
450  }
451  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
452 
453  fCEvents->Fill(1);
455 
456  //------------------------------------------------
457  // First check if the event has proper B
458  //------------------------------------------------
459  fBzkG = (Double_t)aodEvent->GetMagneticField();
460  AliKFParticle::SetField(fBzkG);
461  if (TMath::Abs(fBzkG)<0.001) {
462  return;
463  }
464  fCEvents->Fill(2);
465 
468 
469  //------------------------------------------------
470  // MC analysis setting
471  //------------------------------------------------
472  TClonesArray *mcArray = 0;
473  AliAODMCHeader *mcHeader=0;
474  if (fUseMCInfo) {
475  // MC array need for maching
476  mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
477  if (!mcArray) {
478  AliError("Could not find Monte-Carlo in AOD");
479  return;
480  }
481  fCEvents->Fill(6); // in case of MC events
482 
483  // load MC header
484  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
485  if (!mcHeader) {
486  AliError("AliAnalysisTaskSEXic2eleXifromAODtracks::UserExec: MC header branch not found!\n");
487  return;
488  }
489  fCEvents->Fill(7); // in case of MC events
490 
491  Double_t zMCVertex = mcHeader->GetVtxZ();
492  if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()) {
493  AliDebug(2,Form("Event rejected: abs(zVtxMC)=%f > fAnalCuts->GetMaxVtxZ()=%f",zMCVertex,fAnalCuts->GetMaxVtxZ()));
494  return;
495  } else {
496  fCEvents->Fill(17); // in case of MC events
497  }
498  if ((TMath::Abs(zMCVertex) < fAnalCuts->GetMaxVtxZ()) && (!fAnalCuts->IsEventRejectedDuePhysicsSelection()) && (!fAnalCuts->IsEventRejectedDueToTrigger())) {
499  MakeMCAnalysis(mcArray);
500  }
501  }
502 
503  //------------------------------------------------
504  // Event selection
505  //------------------------------------------------
506  fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
507  if (!fVtx1) return;
508 
509  Double_t pos[3],cov[6];
510  fVtx1->GetXYZ(pos);
511  fVtx1->GetCovarianceMatrix(cov);
512  fV1 = new AliESDVertex(pos,cov,100.,100,fVtx1->GetName());
513  fVtxZ = pos[2];
514 
515  Bool_t fIsTriggerNotOK = fAnalCuts->IsEventRejectedDueToTrigger();
516  Bool_t fIsPhysSelNotOK = fAnalCuts->IsEventRejectedDuePhysicsSelection();
517  Bool_t fIsNoVertex = fAnalCuts->IsEventRejectedDueToNotRecoVertex();
518  if(!fIsTriggerNotOK && !fIsPhysSelNotOK && !fIsNoVertex && fabs(fVtx1->GetZ())<fAnalCuts->GetMaxVtxZ()) fCEvents->Fill(3);
519  if(!fIsEventSelected) {
520  delete fV1;
521  return;
522  }
523  fCEvents->Fill(4);
524 
525  fIsMB=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kMB)==(AliVEvent::kMB);
526  fIsSemi=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kSemiCentral)==(AliVEvent::kSemiCentral);
527  fIsCent=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kCentral)==(AliVEvent::kCentral);
528  fIsINT7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kINT7)==(AliVEvent::kINT7);
529  fIsEMC7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kEMC7)==(AliVEvent::kEMC7);
531  if(fIsMB) fHTrigger->Fill(1);
532  if(fIsSemi) fHTrigger->Fill(2);
533  if(fIsCent) fHTrigger->Fill(3);
534  if(fIsINT7) fHTrigger->Fill(4);
535  if(fIsEMC7) fHTrigger->Fill(5);
536  if(fIsMB|fIsSemi|fIsCent) fHTrigger->Fill(7);
537  if(fIsINT7|fIsEMC7) fHTrigger->Fill(8);
538  if(fIsMB&fIsSemi) fHTrigger->Fill(10);
539  if(fIsMB&fIsCent) fHTrigger->Fill(11);
540  if(fIsINT7&fIsEMC7) fHTrigger->Fill(12);
541 
542  if(fUseCentralityV0M){
543  AliCentrality *cent = aodEvent->GetCentrality();
544  fCentrality = cent->GetCentralityPercentile("V0M");
545  }else{
546  fCentrality = 1.;
547  }
548  if(fCentrality<0.||fCentrality>100.-0.0000001) {
549  delete fV1;
550  return;
551  }
552  fHCentrality->Fill(fCentrality);
553  fRunNumber = aodEvent->GetRunNumber();
554 
555  Int_t runnumber_offset = 0;
556  Int_t runnumber = aodEvent->GetRunNumber();
557  if(runnumber<=131000&&runnumber>=114000){
558  runnumber_offset = 114000;//lhc10bcde
559  }else if(runnumber<=196000&&runnumber>=195000){
560  runnumber_offset = 195000;//lhc13bc
561  }else if(runnumber<=170593&&runnumber>=167902){
562  runnumber_offset = 167902;//lhc11h
563  }
564  fHistonEvtvsRunNumber->Fill(runnumber-runnumber_offset,1.);
565 
566  //------------------------------------------------
567  // Check if the event has v0 candidate
568  //------------------------------------------------
569  //Int_t nv0 = aodEvent->GetNumberOfV0s();
570  fCEvents->Fill(5);
571 
572 
573  //------------------------------------------------
574  // Main analysis done in this function
575  //------------------------------------------------
576  MakeAnalysis(aodEvent,mcArray);
577 
578 
579  PostData(1,fOutput);
580  PostData(3,fOutputAll);
581  PostData(4,fVariablesTree);
582  PostData(5,fEleVariablesTree);
583  PostData(6,fCascVariablesTree);
584  PostData(7,fMCVariablesTree);
585  PostData(8,fCounter);
586  PostData(9,fMCEleVariablesTree);
587  PostData(10,fMCCascVariablesTree);
588 
589  fIsEventSelected=kFALSE;
590 
591  delete fV1;
592  return;
593 }
594 
595 //________________________________________ terminate ___________________________
597 {
598  // The Terminate() function is the last function to be called during
599  // a query. It always runs on the client, it can be used to present
600  // the results graphically or save the results to file.
601 
602  //AliInfo("Terminate","");
603  AliAnalysisTaskSE::Terminate();
604 
605  fOutput = dynamic_cast<TList*> (GetOutputData(1));
606  if (!fOutput) {
607  AliError("fOutput not available");
608  return;
609  }
610 
611  fOutputAll = dynamic_cast<TList*> (GetOutputData(3));
612  if (!fOutputAll) {
613  AliError("fOutputAll not available");
614  return;
615  }
616 
617  return;
618 }
619 
620 //___________________________________________________________________________
622 {
623  //
624  // UserCreateOutputObject
625  //
626  //AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
627 
628  //------------------------------------------------
629  // output object setting
630  //------------------------------------------------
631  fOutput = new TList();
632  fOutput->SetOwner();
633  fOutput->SetName("chist0");
634  DefineGeneralHistograms(); // define general histograms
635  PostData(1,fOutput);
636 
637  fOutputAll = new TList();
638  fOutputAll->SetOwner();
639  fOutputAll->SetName("anahisto");
640  DefineAnalysisHistograms(); // define general histograms
641  PostData(3,fOutputAll);
642 
644  PostData(4,fVariablesTree);
645 
647  PostData(5,fEleVariablesTree);
648 
650  PostData(6,fCascVariablesTree);
651 
653  PostData(7,fMCVariablesTree);
654 
656  PostData(9,fMCEleVariablesTree);
657 
659  PostData(10,fMCCascVariablesTree);
660 
661  //Counter for Normalization
662  TString normName="NormalizationCounter";
663  AliAnalysisDataContainer *cont = GetOutputSlot(8)->GetContainer();
664  if(cont)normName=(TString)cont->GetName();
665  fCounter = new AliNormalizationCounter(normName.Data());
666  fCounter->Init();
667  PostData(8,fCounter);
668 
669  if(fDoEventMixing){
670  fElectronTracks = new TObjArray();
671  fElectronTracks->SetOwner();
672 
674  fEventBuffer = new TTree*[fNOfPools];
675  for(Int_t i=0; i<fNOfPools; i++){
676  fEventBuffer[i]=new TTree(Form("EventBuffer_%d",i), "Temporary buffer for event mixing");
677  fEventBuffer[i]->Branch("zVertex", &fVtxZ);
678  fEventBuffer[i]->Branch("centrality", &fCentrality);
679  fEventBuffer[i]->Branch("eventInfo", "TObjString",&fEventInfo);
680  fEventBuffer[i]->Branch("earray", "TObjArray", &fElectronTracks);
681  }
682  }
683 
684 
685  return;
686 }
687 
688 //-------------------------------------------------------------------------------
690 (
691  AliAODEvent *aodEvent, TClonesArray *mcArray
692  )
693 {
694  //
695  // Main Analysis part
696  //
697  //------------------------------------------------
698  // Select good track before hand to save time
699  //------------------------------------------------
700  if(fDoEventMixing && fElectronTracks) fElectronTracks->Delete();
701 
702  Int_t nCascs= aodEvent->GetNumberOfCascades();
703  Int_t nTracks= aodEvent->GetNumberOfTracks();
704 
705  Bool_t seleTrkFlags[nTracks];
706  Int_t nSeleTrks=0;
707  SelectTrack(aodEvent,nTracks,nSeleTrks,seleTrkFlags,mcArray);
708 
709  Bool_t seleCascFlags[nCascs];
710  Int_t nSeleCasc=0;
711  SelectCascade(aodEvent,nCascs,nSeleCasc,seleCascFlags,mcArray);
712 
713  Int_t runnumber_offset = 0;
714  Int_t runnumber = aodEvent->GetRunNumber();
715  if(runnumber<=131000&&runnumber>=114000){
716  runnumber_offset = 114000;//lhc10bcde
717  }else if(runnumber<=196000&&runnumber>=195000){
718  runnumber_offset = 195000;//lhc13bc
719  }else if(runnumber<=170593&&runnumber>=167902){
720  runnumber_offset = 167902;//lhc11h
721  }
722  fHistonElevsRunNumber->Fill(runnumber-runnumber_offset,nSeleTrks);
723  fHistonXivsRunNumber->Fill(runnumber-runnumber_offset,nSeleCasc);
724 
725  //------------------------------------------------
726  // Cascade loop
727  //------------------------------------------------
728  for (Int_t icasc = 0; icasc<nCascs; icasc++) {
729  if(!seleCascFlags[icasc]) continue;
730  AliAODcascade *casc = aodEvent->GetCascade(icasc);
731  if(!casc) continue;
732 
733  AliAODTrack *cptrack = (AliAODTrack*)(casc->GetDaughter(0));
734  AliAODTrack *cntrack = (AliAODTrack*)(casc->GetDaughter(1));
735  AliAODTrack *cbtrack = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0));
736 
737  //------------------------------------------------
738  // track loop
739  //------------------------------------------------
740  for (Int_t itrk = 0; itrk<nTracks; itrk++) {
741  if(!seleTrkFlags[itrk]) continue;
742  AliAODTrack *trk = (AliAODTrack*)aodEvent->GetTrack(itrk);
743  if(trk->GetID()<0) continue;
744 
745  Int_t cpid = cptrack->GetID();
746  Int_t cnid = cntrack->GetID();
747  Int_t cbid = cbtrack->GetID();
748  Int_t lpid = trk->GetID();
749  if((cpid==lpid)||(cnid==lpid)||(cbid==lpid)) continue;
750 
751  //if(!fAnalCuts->SelectWithRoughCuts(v0,trk)) continue;
752 
753  AliAODVertex *secVert = ReconstructSecondaryVertex(casc,trk,aodEvent);//Fake, prim vertex is just used as secondary vertex. place holder for future
754  if(!secVert) continue;
755 
756  AliAODRecoCascadeHF *exobj = MakeCascadeHF(casc,trk,aodEvent,secVert,false);
757  if(!exobj) {
758  continue;
759  }
760 
761  FillROOTObjects(exobj, casc,trk,mcArray,false);
762 
763  exobj->GetSecondaryVtx()->RemoveDaughters();
764  exobj->UnsetOwnPrimaryVtx();
765  delete exobj;exobj=NULL;
766  delete secVert;
767  }
768  }
769 
770  if(fDoEventMixing){
771  fEventInfo->SetString(Form("Ev%d_esd%d_E%d",AliAnalysisManager::GetAnalysisManager()->GetNcalls(),((AliAODHeader*)aodEvent->GetHeader())->GetEventNumberESDFile(),fElectronTracks->GetEntries()));
772  Int_t ind=GetPoolIndex(fVtxZ,fCentrality);
773  if(ind>=0 && ind<fNOfPools){
774  if(fEventBuffer[ind]->GetEntries() >= fNumberOfEventsForMixing){
775  DoEventMixingWithPools(ind,aodEvent,seleCascFlags);
776  //ResetPool(ind);
777  }
778  fEventBuffer[ind]->Fill();
779  }
780  }
781 }
782 
783 
786 {
787  //
788  // Define tree variables
789  //
790 
791  const char* nameoutput = GetOutputSlot(4)->GetContainer()->GetName();
792  fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
793  Int_t nVar = 86;
794  fCandidateVariables = new Float_t [nVar];
795  TString * fCandidateVariableNames = new TString[nVar];
796 
797  fCandidateVariableNames[ 0]="Centrality";
798  fCandidateVariableNames[ 1]="InvMassEleXi";
799  fCandidateVariableNames[ 2]="EleXiPt";
800  fCandidateVariableNames[ 3]="EleXiPx";
801  fCandidateVariableNames[ 4]="EleXiPy";
802  fCandidateVariableNames[ 5]="EleXiPz";
803  fCandidateVariableNames[ 6]="ElePx";
804  fCandidateVariableNames[ 7]="ElePy";
805  fCandidateVariableNames[ 8]="ElePz";
806  fCandidateVariableNames[ 9]="XiPx";
807  fCandidateVariableNames[10]="XiPy";
808  fCandidateVariableNames[11]="XiPz";
809  fCandidateVariableNames[12]="XiCharge";
810  fCandidateVariableNames[13]="MassXi";
811  fCandidateVariableNames[14]="MassLambda";
812  fCandidateVariableNames[15]="Eled0";
813  fCandidateVariableNames[16]="Xid0";
814  fCandidateVariableNames[17]="nSigmaTPCele";
815  fCandidateVariableNames[18]="nSigmaTOFele";
816  fCandidateVariableNames[19]="nSigmaTPCpr_etrk";
817  fCandidateVariableNames[20]="nSigmaTOFpr_etrk";
818  fCandidateVariableNames[21]="nSigmaTPCka_etrk";
819  fCandidateVariableNames[22]="nSigmaTOFka_etrk";
820  fCandidateVariableNames[23]="nSigmaTPCv0pr";
821  fCandidateVariableNames[24]="nSigmaTOFv0pr";
822  fCandidateVariableNames[25]="nSigmaTPCv0pi";
823  fCandidateVariableNames[26]="nSigmaTOFv0pi";
824  fCandidateVariableNames[27]="nSigmaTPCbachpi";
825  fCandidateVariableNames[28]="nSigmaTOFbachpi";
826  fCandidateVariableNames[29]="EleCharge";
827  fCandidateVariableNames[30]="Mixing";
828  fCandidateVariableNames[31]="DcaXiDaughters";
829  fCandidateVariableNames[32]="DcaV0Daughters";
830  fCandidateVariableNames[33]="DecayLengthXi";
831  fCandidateVariableNames[34]="CosPointingAngleXi";
832  fCandidateVariableNames[35]="DcaV0toPrimVertex";
833  fCandidateVariableNames[36]="DcaPostoPrimVertex";
834  fCandidateVariableNames[37]="DcaNegtoPrimVertex";
835  fCandidateVariableNames[38]="DcaBachtoPrimVertex";
836  fCandidateVariableNames[39]="DecayLengthV0";
837  fCandidateVariableNames[40]="CosPointingAngleV0";
838 
839  fCandidateVariableNames[41]="mcpdgxic";
840  fCandidateVariableNames[42]="mclabxic";
841  fCandidateVariableNames[43]="mcxicpx";
842  fCandidateVariableNames[44]="mcxicpy";
843  fCandidateVariableNames[45]="mcxicpz";
844  fCandidateVariableNames[46]="mcelepx";
845  fCandidateVariableNames[47]="mcelepy";
846  fCandidateVariableNames[48]="mcelepz";
847  fCandidateVariableNames[49]="mccascpx";
848  fCandidateVariableNames[50]="mccascpy";
849  fCandidateVariableNames[51]="mccascpz";
850 
851  fCandidateVariableNames[52]="mcpdgele";
852  fCandidateVariableNames[53]="mcpdgcasc";
853  fCandidateVariableNames[54]="mcpdgmomele";
854  fCandidateVariableNames[55]="mcpdgmomcasc";
855  fCandidateVariableNames[56]="mcpdggrmomele";
856  fCandidateVariableNames[57]="mcpdggrmomcasc";
857  fCandidateVariableNames[58]="mcngenele";
858  fCandidateVariableNames[59]="mcngencasc";
859 
860  fCandidateVariableNames[60]="nSigmaTPCpi_etrk";
861  fCandidateVariableNames[61]="nSigmaTOFpi_etrk";
862 
863  fCandidateVariableNames[62]="V0PosPx";
864  fCandidateVariableNames[63]="V0PosPy";
865  fCandidateVariableNames[64]="V0PosPz";
866  fCandidateVariableNames[65]="V0NegPx";
867  fCandidateVariableNames[66]="V0NegPy";
868  fCandidateVariableNames[67]="V0NegPz";
869  fCandidateVariableNames[68]="V0VertX";
870  fCandidateVariableNames[69]="V0VertY";
871  fCandidateVariableNames[70]="V0VertZ";
872  fCandidateVariableNames[71]="BachPx";
873  fCandidateVariableNames[72]="BachPy";
874  fCandidateVariableNames[73]="BachPz";
875  fCandidateVariableNames[74]="XiVertX";
876  fCandidateVariableNames[75]="XiVertY";
877  fCandidateVariableNames[76]="XiVertZ";
878  fCandidateVariableNames[77]="PrimVertX";
879  fCandidateVariableNames[78]="PrimVertY";
880  fCandidateVariableNames[79]="PrimVertZ";
881 
882  fCandidateVariableNames[80]="MassOmega";
883 
884  fCandidateVariableNames[81]= "EleITSMatch";
885  fCandidateVariableNames[82]= "BachITSMatch";
886  fCandidateVariableNames[83]= "V0PosITSMatch";
887  fCandidateVariableNames[84]= "V0NegITSMatch";
888 
889  fCandidateVariableNames[85]="EvNumber";
890 
891  for (Int_t ivar=0; ivar<nVar; ivar++) {
892  fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
893  }
894 
895  return;
896 }
897 
899 void AliAnalysisTaskSEXic2eleXifromAODtracks::FillROOTObjects(AliAODRecoCascadeHF *exobj, AliAODcascade *casc, AliAODTrack *trk, TClonesArray *mcArray, Bool_t mixing_flag)
900 {
901  //
902  // Fill histograms or tree depending on fWriteVariableTree
903  //
904  if(!trk) return;
905  if(!casc) return;
906 
907  for(Int_t i=0;i<86;i++){
908  fCandidateVariables[i] = -9999.;
909  }
910 
911 
912  AliAODTrack *cptrack = (AliAODTrack*)(casc->GetDaughter(0));
913  AliAODTrack *cntrack = (AliAODTrack*)(casc->GetDaughter(1));
914  AliAODTrack *cbtrack = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0));
915  if(cptrack->Charge()<0 && cntrack->Charge()>0){
916  cptrack = (AliAODTrack*)(casc->GetDaughter(1));
917  cntrack = (AliAODTrack*)(casc->GetDaughter(0));
918  }
919 // Double_t d0z0[2],covd0z0[3];
920 // cptrack->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0,covd0z0);//propagate to primary vertex for debugging
921 // cntrack->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0,covd0z0);//propagate to primary vertex for debugging
922 // cbtrack->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0,covd0z0);//propagate to primary vertex for debugging
923 
924  Double_t posVtx[3] = {0.,0.,0.};
925  fVtx1->GetXYZ(posVtx);
926 
927 
929  UInt_t pdgdg[2]={11,3312};
930  fCandidateVariables[ 1] = exobj->InvMass(2,pdgdg);
931  fCandidateVariables[ 2] = exobj->Pt();
932  fCandidateVariables[ 3] = exobj->Px();
933  fCandidateVariables[ 4] = exobj->Py();
934  fCandidateVariables[ 5] = exobj->Pz();
935  fCandidateVariables[ 6] = exobj->PxProng(0);
936  fCandidateVariables[ 7] = exobj->PyProng(0);
937  fCandidateVariables[ 8] = exobj->PzProng(0);
938  fCandidateVariables[ 9] = exobj->PxProng(1);
939  fCandidateVariables[10] = exobj->PyProng(1);
940  fCandidateVariables[11] = exobj->PzProng(1);
941  fCandidateVariables[12] = casc->ChargeXi();
942  fCandidateVariables[13] = casc->MassXi();
943  if(casc->ChargeXi()<0)
944  fCandidateVariables[14] = casc->MassLambda();
945  else
946  fCandidateVariables[14] = casc->MassAntiLambda();
947  fCandidateVariables[15] = exobj->Getd0Prong(0);
948  fCandidateVariables[16] = exobj->Getd0Prong(1);
949 
950  Double_t nSigmaTPCele = -9999.;
951  Double_t nSigmaTOFele = -9999.;
952  if(fAnalCuts->GetIsUsePID()&&!mixing_flag)
953  {
954  nSigmaTPCele = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kElectron);
955  nSigmaTOFele = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(trk,AliPID::kElectron);
956  fCandidateVariables[17] = nSigmaTPCele;
957  fCandidateVariables[18] = nSigmaTOFele;
958 
959  Double_t nSigmaTPCpr_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kProton);
960  Double_t nSigmaTOFpr_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(trk,AliPID::kProton);
961  Double_t nSigmaTPCka_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kKaon);
962  Double_t nSigmaTOFka_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(trk,AliPID::kKaon);
963  Double_t nSigmaTPCpi_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kPion);
964  Double_t nSigmaTOFpi_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(trk,AliPID::kPion);
965  fCandidateVariables[19] = nSigmaTPCpr_etrk;
966  fCandidateVariables[20] = nSigmaTOFpr_etrk;
967  fCandidateVariables[21] = nSigmaTPCka_etrk;
968  fCandidateVariables[22] = nSigmaTOFka_etrk;
969  fCandidateVariables[60] = nSigmaTPCpi_etrk;
970  fCandidateVariables[61] = nSigmaTOFpi_etrk;
971  }
972 
973  Double_t nSigmaTPCv0pr=-9999.;
974  Double_t nSigmaTOFv0pr=-9999.;
975  Double_t nSigmaTPCv0pi=-9999.;
976  Double_t nSigmaTOFv0pi=-9999.;
977  Double_t nSigmaTPCbachpi=-9999.;
978  Double_t nSigmaTOFbachpi=-9999.;
979  if(fAnalCuts->GetUseCascadePID()&&!mixing_flag)
980  {
981  if(casc->ChargeXi()>0){
982  nSigmaTPCv0pr = fAnalCuts->GetPidCascPr()->GetPidResponse()->NumberOfSigmasTPC(cntrack,AliPID::kProton);
983  nSigmaTOFv0pr = fAnalCuts->GetPidCascPr()->GetPidResponse()->NumberOfSigmasTOF(cntrack,AliPID::kProton);
984  nSigmaTPCv0pi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTPC(cptrack,AliPID::kPion);
985  nSigmaTOFv0pi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTOF(cptrack,AliPID::kPion);
986  nSigmaTPCbachpi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTPC(cbtrack,AliPID::kPion);
987  nSigmaTOFbachpi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTOF(cbtrack,AliPID::kPion);
988  }else{
989  nSigmaTPCv0pr = fAnalCuts->GetPidCascPr()->GetPidResponse()->NumberOfSigmasTPC(cptrack,AliPID::kProton);
990  nSigmaTOFv0pr = fAnalCuts->GetPidCascPr()->GetPidResponse()->NumberOfSigmasTOF(cptrack,AliPID::kProton);
991  nSigmaTPCv0pi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTPC(cntrack,AliPID::kPion);
992  nSigmaTOFv0pi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTOF(cntrack,AliPID::kPion);
993  nSigmaTPCbachpi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTPC(cbtrack,AliPID::kPion);
994  nSigmaTOFbachpi = fAnalCuts->GetPidCascPi()->GetPidResponse()->NumberOfSigmasTOF(cbtrack,AliPID::kPion);
995  }
996  fCandidateVariables[23] = nSigmaTPCv0pr;
997  fCandidateVariables[24] = nSigmaTOFv0pr;
998  fCandidateVariables[25] = nSigmaTPCv0pi;
999  fCandidateVariables[26] = nSigmaTOFv0pi;
1000  fCandidateVariables[27] = nSigmaTPCbachpi;
1001  fCandidateVariables[28] = nSigmaTOFbachpi;
1002  }
1003  fCandidateVariables[29] = trk->Charge();
1004  fCandidateVariables[30] = (Float_t) mixing_flag;
1005  fCandidateVariables[31] = casc->DcaXiDaughters();
1006  fCandidateVariables[32] = casc->DcaV0Daughters();
1007  fCandidateVariables[33] = casc->DecayLengthXi(posVtx[0],posVtx[1],posVtx[2]);
1008  fCandidateVariables[34] = casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
1009  fCandidateVariables[35] = casc->DcaV0ToPrimVertex();
1010  fCandidateVariables[36] = casc->DcaPosToPrimVertex();
1011  fCandidateVariables[37] = casc->DcaNegToPrimVertex();
1012  fCandidateVariables[38] = casc->DcaBachToPrimVertex();
1013  fCandidateVariables[39] = casc->DecayLengthV0();
1014  fCandidateVariables[40] = casc->CosPointingAngle(casc->GetDecayVertexXi());
1015 
1016  AliAODMCParticle *mcxic = 0;
1017  AliAODMCParticle *mcele = 0;
1018  AliAODMCParticle *mccasc = 0;
1019  Int_t mclabxic = 0;
1020  Int_t mcpdgele_array[100];
1021  Int_t mcpdgcasc_array[100];
1022  Int_t mclabelele_array[100];
1023  Int_t mclabelcasc_array[100];
1024  Int_t mcngen_ele = -9999;
1025  Int_t mcngen_casc = -9999;
1026 
1027  if(fUseMCInfo && mcArray){
1028 
1029  mclabxic = MatchToMC(exobj,mcArray,mcpdgele_array, mcpdgcasc_array,mclabelele_array,mclabelcasc_array,mcngen_ele,mcngen_casc);
1030 
1031  if(mclabxic>-1){
1032  mcxic = (AliAODMCParticle*) mcArray->At(mclabxic);
1033  if(mclabelele_array[0]>=0)
1034  mcele = (AliAODMCParticle*) mcArray->At(mclabelele_array[0]);
1035  if(mclabelcasc_array[0]>=0)
1036  mccasc = (AliAODMCParticle*) mcArray->At(mclabelcasc_array[0]);
1037  if(mcxic){
1038  fCandidateVariables[41] = mcxic->GetPdgCode();
1039  fCandidateVariables[42] = mcxic->Label();
1040  fCandidateVariables[43] = mcxic->Px();
1041  fCandidateVariables[44] = mcxic->Py();
1042  fCandidateVariables[45] = mcxic->Pz();
1043  }
1044  if(mcele){
1045  fCandidateVariables[46] = mcele->Px();
1046  fCandidateVariables[47] = mcele->Py();
1047  fCandidateVariables[48] = mcele->Pz();
1048  }
1049  if(mccasc){
1050  fCandidateVariables[49] = mccasc->Px();
1051  fCandidateVariables[50] = mccasc->Py();
1052  fCandidateVariables[51] = mccasc->Pz();
1053  }
1054  }
1055  fCandidateVariables[52] = mcpdgele_array[0];
1056  fCandidateVariables[53] = mcpdgcasc_array[0];
1057  fCandidateVariables[54] = mcpdgele_array[1];
1058  fCandidateVariables[55] = mcpdgcasc_array[1];
1059  fCandidateVariables[56] = mcpdgele_array[2];
1060  fCandidateVariables[57] = mcpdgcasc_array[2];
1061  fCandidateVariables[58] = mcngen_ele;
1062  fCandidateVariables[59] = mcngen_casc;
1063  }
1064  fCandidateVariables[62] = casc->MomPosX();
1065  fCandidateVariables[63] = casc->MomPosY();
1066  fCandidateVariables[64] = casc->MomPosZ();
1067  fCandidateVariables[65] = casc->MomNegX();
1068  fCandidateVariables[66] = casc->MomNegY();
1069  fCandidateVariables[67] = casc->MomNegZ();
1070  fCandidateVariables[68] = casc->DecayVertexV0X();
1071  fCandidateVariables[69] = casc->DecayVertexV0Y();
1072  fCandidateVariables[70] = casc->DecayVertexV0Z();
1073  fCandidateVariables[71] = casc->MomBachX();
1074  fCandidateVariables[72] = casc->MomBachY();
1075  fCandidateVariables[73] = casc->MomBachZ();
1076  fCandidateVariables[74] = casc->DecayVertexXiX();
1077  fCandidateVariables[75] = casc->DecayVertexXiY();
1078  fCandidateVariables[76] = casc->DecayVertexXiZ();
1079  fCandidateVariables[77] = fVtx1->GetX();
1080  fCandidateVariables[78] = fVtx1->GetY();
1081  fCandidateVariables[79] = fVtx1->GetZ();
1082 
1083  fCandidateVariables[80] = casc->MassOmega();
1084 
1085  if(trk) fCandidateVariables[81] = trk->GetITSClusterMap();
1086  if(cbtrack) fCandidateVariables[82] = cbtrack->GetITSClusterMap();
1087  if(cptrack) fCandidateVariables[83] = cptrack->GetITSClusterMap();
1088  if(cntrack) fCandidateVariables[84] = cntrack->GetITSClusterMap();
1089 
1091 
1092  if(fWriteVariableTree)
1093  fVariablesTree->Fill();
1094 
1096  {
1097  Double_t cont[3];
1098  cont[0] = exobj->InvMass(2,pdgdg);
1099  cont[1] = exobj->Pt();
1100  cont[2] = fCentrality;
1101  fHistoEleXiMass->Fill(cont);
1102 
1103  Double_t cont2[3];
1104  cont2[0] = exobj->InvMass(2,pdgdg);
1105  cont2[1] = trk->Pt();
1106  cont2[2] = fCentrality;
1107 
1108  Double_t cont_eleptvseta[3];
1109  cont_eleptvseta[0] = trk->Pt();
1110  cont_eleptvseta[1] = trk->Eta();
1111  cont_eleptvseta[2] = fCentrality;
1112 
1113  Double_t cont_eleptvsxipt[3];
1114  cont_eleptvsxipt[0] = trk->Pt();
1115  cont_eleptvsxipt[1] = sqrt(casc->MomXiX()*casc->MomXiX()+casc->MomXiY()*casc->MomXiY());
1116  cont_eleptvsxipt[2] = fCentrality;
1117 
1118  Double_t cont_eleptvsd0[3];
1119  cont_eleptvsd0[0] = trk->Pt();
1120  cont_eleptvsd0[1] = exobj->Getd0Prong(0)*trk->Charge();
1121  cont_eleptvsd0[2] = fCentrality;
1122 
1123  if(mixing_flag){
1124  if(trk->Charge()*casc->ChargeXi()<0){
1125  fHistoEleXiMassRSMix->Fill(cont);
1126  fHistoEleXiMassvsElePtRSMix->Fill(cont2);
1127  if(cont[0]<2.5){
1128  fHistoElePtRSMix->Fill(trk->Pt(),fCentrality);
1129  fHistoElePtvsEtaRSMix->Fill(cont_eleptvseta);
1130  fHistoElePtvsXiPtRSMix->Fill(cont_eleptvsxipt);
1131  fHistoElePtvsd0RSMix->Fill(cont_eleptvsd0);
1132  }
1133  }else{
1134  fHistoEleXiMassWSMix->Fill(cont);
1135  fHistoEleXiMassvsElePtWSMix->Fill(cont2);
1136  if(cont[0]<2.5){
1137  fHistoElePtWSMix->Fill(trk->Pt(),fCentrality);
1138  fHistoElePtvsEtaWSMix->Fill(cont_eleptvseta);
1139  fHistoElePtvsXiPtWSMix->Fill(cont_eleptvsxipt);
1140  fHistoElePtvsd0WSMix->Fill(cont_eleptvsd0);
1141  }
1142  }
1143  }else{
1144  if(trk->Charge()*casc->ChargeXi()<0){
1145  fHistoEleXiMassRS->Fill(cont);
1146  fHistoEleXiMassvsElePtRS->Fill(cont2);
1147  if(cont[0]<2.5){
1148  fHistoElePtRS->Fill(trk->Pt(),fCentrality);
1149  fHistoElePtvsEtaRS->Fill(cont_eleptvseta);
1150  fHistoElePtvsXiPtRS->Fill(cont_eleptvsxipt);
1151  fHistoElePtvsd0RS->Fill(cont_eleptvsd0);
1152 
1153  for(Int_t ih=0;ih<23;ih++){
1154  Double_t cont_eleptvscutvars[3];
1155  cont_eleptvscutvars[0] = trk->Pt();
1156  cont_eleptvscutvars[2] = fCentrality;
1157 
1158  if(ih==0){
1159  cont_eleptvscutvars[1] = trk->GetTPCNcls();
1160  }else if(ih==1){
1161  cont_eleptvscutvars[1] = trk->GetTPCsignalN();
1162  }else if(ih==2){
1163  cont_eleptvscutvars[1] = nSigmaTPCele;
1164  }else if(ih==3){
1165  cont_eleptvscutvars[1] = nSigmaTOFele;
1166  }else if(ih==4){
1167  cont_eleptvscutvars[1] = trk->Eta();
1168  }else if(ih==5){
1169  cont_eleptvscutvars[1] = trk->GetITSNcls();
1170  }else if(ih==6){
1171  if(casc->ChargeXi()<0)
1172  cont_eleptvscutvars[1] = casc->MassLambda();
1173  else
1174  cont_eleptvscutvars[1] = casc->MassAntiLambda();
1175  }else if(ih==7){
1176  cont_eleptvscutvars[1] = casc->MassXi();
1177  }else if(ih==8){
1178  Double_t lPosV0[3];
1179  lPosV0[0] = casc->DecayVertexV0X();
1180  lPosV0[1] = casc->DecayVertexV0Y();
1181  lPosV0[2] = casc->DecayVertexV0Z();
1182  cont_eleptvscutvars[1] = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]);
1183  }else if(ih==9){
1184  Double_t lPosXi[3];
1185  lPosXi[0] = casc->DecayVertexXiX();
1186  lPosXi[1] = casc->DecayVertexXiY();
1187  lPosXi[2] = casc->DecayVertexXiZ();
1188  cont_eleptvscutvars[1] = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]);
1189  }else if(ih==10){
1190  cont_eleptvscutvars[1] = casc->DcaV0Daughters();
1191  }else if(ih==11){
1192  cont_eleptvscutvars[1] = casc->DcaXiDaughters();
1193  }else if(ih==12){
1194  cont_eleptvscutvars[1] = casc->DcaBachToPrimVertex();
1195  }else if(ih==13){
1196  if(casc->ChargeXi()<0.)
1197  cont_eleptvscutvars[1] = casc->DcaPosToPrimVertex();
1198  else
1199  cont_eleptvscutvars[1] = casc->DcaNegToPrimVertex();
1200  }else if(ih==14){
1201  if(casc->ChargeXi()>0.)
1202  cont_eleptvscutvars[1] = casc->DcaPosToPrimVertex();
1203  else
1204  cont_eleptvscutvars[1] = casc->DcaNegToPrimVertex();
1205  }else if(ih==15){
1206  cont_eleptvscutvars[1] = casc->CosPointingAngle(casc->GetDecayVertexXi());
1207  }else if(ih==16){
1208  cont_eleptvscutvars[1] = casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
1209  }else if(ih==17){
1210  cont_eleptvscutvars[1] = nSigmaTPCv0pr;
1211  }else if(ih==18){
1212  cont_eleptvscutvars[1] = nSigmaTPCv0pi;
1213  }else if(ih==19){
1214  cont_eleptvscutvars[1] = nSigmaTPCbachpi;
1215  }else if(ih==20){
1216  cont_eleptvscutvars[1] = casc->Eta();
1217  }else if(ih==21){
1218  cont_eleptvscutvars[1] = 0.5*TMath::Log((sqrt(casc->Ptot2Xi())+casc->MomXiZ())/(sqrt(casc->Ptot2Xi())-casc->MomXiZ()));
1219  }else if(ih==22){
1220  Double_t xipx = exobj->PxProng(1);
1221  Double_t xipy = exobj->PyProng(1);
1222  Double_t xipz = exobj->PzProng(1);
1223  Double_t epx = exobj->PxProng(0);
1224  Double_t epy = exobj->PyProng(0);
1225  Double_t epz = exobj->PzProng(0);
1226  cont_eleptvscutvars[1] = acos((xipx*epx+xipy*epy+xipz*epz)/sqrt(xipx*xipx+xipy*xipy+xipz*xipz)/sqrt(epx*epx+epy*epy+epz*epz));
1227  }else{
1228  cont_eleptvscutvars[1] = -9999.;
1229  }
1230 
1231  fHistoElePtvsCutVarsRS[ih]->Fill(cont_eleptvscutvars);
1232  }
1233  }
1234  }else{
1235  fHistoEleXiMassWS->Fill(cont);
1236  fHistoEleXiMassvsElePtWS->Fill(cont2);
1237  if(cont[0]<2.5){
1238  fHistoElePtWS->Fill(trk->Pt(),fCentrality);
1239  fHistoElePtvsEtaWS->Fill(cont_eleptvseta);
1240  fHistoElePtvsXiPtWS->Fill(cont_eleptvsxipt);
1241  fHistoElePtvsd0WS->Fill(cont_eleptvsd0);
1242 
1243  for(Int_t ih=0;ih<23;ih++){
1244  Double_t cont_eleptvscutvars[3];
1245  cont_eleptvscutvars[0] = trk->Pt();
1246  cont_eleptvscutvars[2] = fCentrality;
1247 
1248  if(ih==0){
1249  cont_eleptvscutvars[1] = trk->GetTPCNcls();
1250  }else if(ih==1){
1251  cont_eleptvscutvars[1] = trk->GetTPCsignalN();
1252  }else if(ih==2){
1253  cont_eleptvscutvars[1] = nSigmaTPCele;
1254  }else if(ih==3){
1255  cont_eleptvscutvars[1] = nSigmaTOFele;
1256  }else if(ih==4){
1257  cont_eleptvscutvars[1] = trk->Eta();
1258  }else if(ih==5){
1259  cont_eleptvscutvars[1] = trk->GetITSNcls();
1260  }else if(ih==6){
1261  if(casc->ChargeXi()<0)
1262  cont_eleptvscutvars[1] = casc->MassLambda();
1263  else
1264  cont_eleptvscutvars[1] = casc->MassAntiLambda();
1265  }else if(ih==7){
1266  cont_eleptvscutvars[1] = casc->MassXi();
1267  }else if(ih==8){
1268  Double_t lPosV0[3];
1269  lPosV0[0] = casc->DecayVertexV0X();
1270  lPosV0[1] = casc->DecayVertexV0Y();
1271  lPosV0[2] = casc->DecayVertexV0Z();
1272  cont_eleptvscutvars[1] = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]);
1273  }else if(ih==9){
1274  Double_t lPosXi[3];
1275  lPosXi[0] = casc->DecayVertexXiX();
1276  lPosXi[1] = casc->DecayVertexXiY();
1277  lPosXi[2] = casc->DecayVertexXiZ();
1278  cont_eleptvscutvars[1] = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]);
1279  }else if(ih==10){
1280  cont_eleptvscutvars[1] = casc->DcaV0Daughters();
1281  }else if(ih==11){
1282  cont_eleptvscutvars[1] = casc->DcaXiDaughters();
1283  }else if(ih==12){
1284  cont_eleptvscutvars[1] = casc->DcaBachToPrimVertex();
1285  }else if(ih==13){
1286  if(casc->ChargeXi()<0.)
1287  cont_eleptvscutvars[1] = casc->DcaPosToPrimVertex();
1288  else
1289  cont_eleptvscutvars[1] = casc->DcaNegToPrimVertex();
1290  }else if(ih==14){
1291  if(casc->ChargeXi()>0.)
1292  cont_eleptvscutvars[1] = casc->DcaPosToPrimVertex();
1293  else
1294  cont_eleptvscutvars[1] = casc->DcaNegToPrimVertex();
1295  }else if(ih==15){
1296  cont_eleptvscutvars[1] = casc->CosPointingAngle(casc->GetDecayVertexXi());
1297  }else if(ih==16){
1298  cont_eleptvscutvars[1] = casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
1299  }else if(ih==17){
1300  cont_eleptvscutvars[1] = nSigmaTPCv0pr;
1301  }else if(ih==18){
1302  cont_eleptvscutvars[1] = nSigmaTPCv0pi;
1303  }else if(ih==19){
1304  cont_eleptvscutvars[1] = nSigmaTPCbachpi;
1305  }else if(ih==20){
1306  cont_eleptvscutvars[1] = casc->Eta();
1307  }else if(ih==21){
1308  cont_eleptvscutvars[1] = 0.5*TMath::Log((sqrt(casc->Ptot2Xi())+casc->MomXiZ())/(sqrt(casc->Ptot2Xi())-casc->MomXiZ()));
1309  }else if(ih==22){
1310  Double_t xipx = exobj->PxProng(1);
1311  Double_t xipy = exobj->PyProng(1);
1312  Double_t xipz = exobj->PzProng(1);
1313  Double_t epx = exobj->PxProng(0);
1314  Double_t epy = exobj->PyProng(0);
1315  Double_t epz = exobj->PzProng(0);
1316  cont_eleptvscutvars[1] = acos((xipx*epx+xipy*epy+xipz*epz)/sqrt(xipx*xipx+xipy*xipy+xipz*xipz)/sqrt(epx*epx+epy*epy+epz*epz));
1317  }else{
1318  cont_eleptvscutvars[1] = -9999.;
1319  }
1320 
1321  fHistoElePtvsCutVarsWS[ih]->Fill(cont_eleptvscutvars);
1322  }
1323  }
1324  }
1325  }
1326 
1327  if(fUseMCInfo){
1328  if(mcxic){
1329  Int_t pdgcode = mcxic->GetPdgCode();
1330  if(abs(pdgcode)==4132 && abs(mcpdgele_array[1])==4132 && abs(mcpdgcasc_array[1])==4132){
1331  fHistoEleXiMassMCS->Fill(cont);
1332  fHistoEleXiMassvsElePtMCS->Fill(cont2);
1333  if(cont[0]<2.5){
1334  fHistoElePtMCS->Fill(trk->Pt(),fCentrality);
1335  fHistoElePtvsEtaMCS->Fill(cont_eleptvseta);
1336  fHistoElePtvsXiPtMCS->Fill(cont_eleptvsxipt);
1337  fHistoElePtvsd0MCS->Fill(cont_eleptvsd0);
1338 
1339  Double_t cont_eleptvsxiptvsxicpt[4];
1340  cont_eleptvsxiptvsxicpt[0] = cont_eleptvsxipt[0];
1341  cont_eleptvsxiptvsxicpt[1] = cont_eleptvsxipt[1];
1342  cont_eleptvsxiptvsxicpt[2] = mcxic->Pt();
1343  cont_eleptvsxiptvsxicpt[3] = cont_eleptvsxipt[2];
1344  fHistoElePtvsXiPtvsXicPtMCS->Fill(cont_eleptvsxiptvsxicpt);
1345 
1346  Int_t labmotherxic = mcxic->GetMother();
1347  if(labmotherxic>=0){
1348  AliAODMCParticle *motherxic = (AliAODMCParticle*)mcArray->At(labmotherxic);
1349  Int_t pdgmotherxic = motherxic->GetPdgCode();
1350  if(TMath::Abs(pdgmotherxic)==511||TMath::Abs(pdgmotherxic)==521||TMath::Abs(pdgmotherxic)==5122||TMath::Abs(pdgmotherxic)==5132||TMath::Abs(pdgmotherxic)==5232||TMath::Abs(pdgmotherxic)==5332){
1351  fHistoElePtvsd0BFeeddownMCS->Fill(cont_eleptvsd0);
1352  }else{
1353  fHistoElePtvsd0PromptMCS->Fill(cont_eleptvsd0);
1354  }
1355  }else{
1356  fHistoElePtvsd0PromptMCS->Fill(cont_eleptvsd0);
1357  }
1358 
1359  for(Int_t ih=0;ih<23;ih++){
1360  Double_t cont_eleptvscutvars[3];
1361  cont_eleptvscutvars[0] = trk->Pt();
1362  cont_eleptvscutvars[2] = fCentrality;
1363 
1364  if(ih==0){
1365  cont_eleptvscutvars[1] = trk->GetTPCNcls();
1366  }else if(ih==1){
1367  cont_eleptvscutvars[1] = trk->GetTPCsignalN();
1368  }else if(ih==2){
1369  cont_eleptvscutvars[1] = nSigmaTPCele;
1370  }else if(ih==3){
1371  cont_eleptvscutvars[1] = nSigmaTOFele;
1372  }else if(ih==4){
1373  cont_eleptvscutvars[1] = trk->Eta();
1374  }else if(ih==5){
1375  cont_eleptvscutvars[1] = trk->GetITSNcls();
1376  }else if(ih==6){
1377  if(casc->ChargeXi()<0)
1378  cont_eleptvscutvars[1] = casc->MassLambda();
1379  else
1380  cont_eleptvscutvars[1] = casc->MassAntiLambda();
1381  }else if(ih==7){
1382  cont_eleptvscutvars[1] = casc->MassXi();
1383  }else if(ih==8){
1384  Double_t lPosV0[3];
1385  lPosV0[0] = casc->DecayVertexV0X();
1386  lPosV0[1] = casc->DecayVertexV0Y();
1387  lPosV0[2] = casc->DecayVertexV0Z();
1388  cont_eleptvscutvars[1] = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]);
1389  }else if(ih==9){
1390  Double_t lPosXi[3];
1391  lPosXi[0] = casc->DecayVertexXiX();
1392  lPosXi[1] = casc->DecayVertexXiY();
1393  lPosXi[2] = casc->DecayVertexXiZ();
1394  cont_eleptvscutvars[1] = TMath::Sqrt(lPosXi[0]*lPosXi[0]+lPosXi[1]*lPosXi[1]);
1395  }else if(ih==10){
1396  cont_eleptvscutvars[1] = casc->DcaV0Daughters();
1397  }else if(ih==11){
1398  cont_eleptvscutvars[1] = casc->DcaXiDaughters();
1399  }else if(ih==12){
1400  cont_eleptvscutvars[1] = casc->DcaBachToPrimVertex();
1401  }else if(ih==13){
1402  if(casc->ChargeXi()<0.)
1403  cont_eleptvscutvars[1] = casc->DcaPosToPrimVertex();
1404  else
1405  cont_eleptvscutvars[1] = casc->DcaNegToPrimVertex();
1406  }else if(ih==14){
1407  if(casc->ChargeXi()>0.)
1408  cont_eleptvscutvars[1] = casc->DcaPosToPrimVertex();
1409  else
1410  cont_eleptvscutvars[1] = casc->DcaNegToPrimVertex();
1411  }else if(ih==15){
1412  cont_eleptvscutvars[1] = casc->CosPointingAngle(casc->GetDecayVertexXi());
1413  }else if(ih==16){
1414  cont_eleptvscutvars[1] = casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
1415  }else if(ih==17){
1416  cont_eleptvscutvars[1] = nSigmaTPCv0pr;
1417  }else if(ih==18){
1418  cont_eleptvscutvars[1] = nSigmaTPCv0pi;
1419  }else if(ih==19){
1420  cont_eleptvscutvars[1] = nSigmaTPCbachpi;
1421  }else if(ih==20){
1422  cont_eleptvscutvars[1] = casc->Eta();
1423  }else if(ih==21){
1424  cont_eleptvscutvars[1] = 0.5*TMath::Log((sqrt(casc->Ptot2Xi())+casc->MomXiZ())/(sqrt(casc->Ptot2Xi())-casc->MomXiZ()));
1425  }else if(ih==22){
1426  Double_t xipx = exobj->PxProng(1);
1427  Double_t xipy = exobj->PyProng(1);
1428  Double_t xipz = exobj->PzProng(1);
1429  Double_t epx = exobj->PxProng(0);
1430  Double_t epy = exobj->PyProng(0);
1431  Double_t epz = exobj->PzProng(0);
1432  cont_eleptvscutvars[1] = acos((xipx*epx+xipy*epy+xipz*epz)/sqrt(xipx*xipx+xipy*xipy+xipz*xipz)/sqrt(epx*epx+epy*epy+epz*epz));
1433  }else{
1434  cont_eleptvscutvars[1] = -9999.;
1435  }
1436 
1437  fHistoElePtvsCutVarsMCS[ih]->Fill(cont_eleptvscutvars);
1438  }
1439  }
1440  }
1441  }
1442  }
1443  }
1444 
1445  return;
1446 }
1447 
1450 {
1451  //
1452  // Define electron tree variables
1453  //
1454 
1455  const char* nameoutput = GetOutputSlot(5)->GetContainer()->GetName();
1456  fEleVariablesTree = new TTree(nameoutput,"electron variables tree");
1457  Int_t nVar = 25;
1458  fCandidateEleVariables = new Float_t [nVar];
1459  TString * fCandidateVariableNames = new TString[nVar];
1460 
1461  fCandidateVariableNames[ 0]="ElePx";
1462  fCandidateVariableNames[ 1]="ElePy";
1463  fCandidateVariableNames[ 2]="ElePz";
1464  fCandidateVariableNames[ 3]="TPCChi2overNDF";
1465  fCandidateVariableNames[ 4]="ITSNcls";
1466  fCandidateVariableNames[ 5]="TPCNcls";
1467  fCandidateVariableNames[ 6]="TPCNclsPID";
1468  fCandidateVariableNames[ 7]="TPCNclsRatio";
1469  fCandidateVariableNames[ 8]="d0R";
1470  fCandidateVariableNames[ 9]="d0Z";
1471  fCandidateVariableNames[10]="ITSClusterMap";
1472  fCandidateVariableNames[11]="nSigmaTPCele";
1473  fCandidateVariableNames[12]="nSigmaTOFele";
1474  fCandidateVariableNames[13]="nSigmaTPCpi";
1475  fCandidateVariableNames[14]="nSigmaTPCka";
1476  fCandidateVariableNames[15]="nSigmaTPCpr";
1477  fCandidateVariableNames[16]="EvNumber";
1478  fCandidateVariableNames[17]="EleCharge";
1479  fCandidateVariableNames[18]="ElePdgCode";
1480  fCandidateVariableNames[19]="EleMotherPdgCode";
1481  fCandidateVariableNames[20]="mcelepx";
1482  fCandidateVariableNames[21]="mcelepy";
1483  fCandidateVariableNames[22]="mcelepz";
1484  fCandidateVariableNames[23]="Centrality";
1485  fCandidateVariableNames[24]="RunNumber";
1486 
1487  for (Int_t ivar=0; ivar<nVar; ivar++) {
1488  fEleVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateEleVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
1489  }
1490 
1491  return;
1492 }
1494 void AliAnalysisTaskSEXic2eleXifromAODtracks::FillElectronROOTObjects(AliAODTrack *trk, TClonesArray *mcArray)
1495 {
1496  //
1497  // Fill histograms or tree depending on fWriteVariableTree
1498  //
1499 
1500  if(!trk) return;
1501 
1502  fHistoBachPt->Fill(trk->Pt());
1503  fHistoElectronQovPtvsPhi->Fill(trk->Phi(),(Double_t)trk->Charge()/trk->Pt());
1504 
1505  if(!fWriteEachVariableTree) return;
1506 
1507  Int_t pdgEle = -9999;
1508  Int_t pdgEleMother = -9999;
1509  Float_t mcepx = -9999;
1510  Float_t mcepy = -9999;
1511  Float_t mcepz = -9999;
1512  if(fUseMCInfo)
1513  {
1514  Int_t labEle = trk->GetLabel();
1515  if(labEle<0) return;
1516  AliAODMCParticle *mcetrk = (AliAODMCParticle*)mcArray->At(labEle);
1517  if(!mcetrk) return;
1518  pdgEle = mcetrk->GetPdgCode();
1519  if(abs(pdgEle)!=11) return;
1520 
1521  fHistoBachPtMCS->Fill(trk->Pt());
1522 
1523  Bool_t hfe_flag = kFALSE;
1524  Int_t labemother = mcetrk->GetMother();
1525  if(labemother>=0){
1526  AliAODMCParticle *motherele = (AliAODMCParticle*)mcArray->At(labemother);
1527  if(!motherele) return;
1528  pdgEleMother = motherele->GetPdgCode();
1529  if(abs(pdgEleMother)>4000&&abs(pdgEleMother)<4400){
1530  hfe_flag = kTRUE;
1531  }
1532  }
1533  if(!hfe_flag) return;
1534  mcepx = mcetrk->Px();
1535  mcepy = mcetrk->Py();
1536  mcepz = mcetrk->Pz();
1537  }
1538 
1539 
1540  for(Int_t i=0;i<25;i++){
1541  fCandidateEleVariables[i] = -9999.;
1542  }
1543 
1544  fCandidateEleVariables[ 0] = trk->Px();
1545  fCandidateEleVariables[ 1] = trk->Py();
1546  fCandidateEleVariables[ 2] = trk->Pz();
1547  fCandidateEleVariables[ 3] = trk->Chi2perNDF();
1548  fCandidateEleVariables[ 4] = trk->GetITSNcls();
1549  fCandidateEleVariables[ 5] = trk->GetTPCncls();
1550  fCandidateEleVariables[ 6] = trk->GetTPCsignalN();
1551  if(trk->GetTPCNclsF()>0)
1552  fCandidateEleVariables[ 7] = (Float_t)trk->GetTPCncls()/(Float_t)trk->GetTPCNclsF();
1553 
1554  Double_t d0z0[2],covd0z0[3];
1555  trk->PropagateToDCA(fVtx1,fBzkG,kVeryBig,d0z0,covd0z0);
1556 
1557  fCandidateEleVariables[ 8] = d0z0[0];
1558  fCandidateEleVariables[ 9] = d0z0[1];
1559  Int_t itsmap = trk->GetITSClusterMap();
1560  Int_t bit1 = 1;
1561  Int_t bit2 = 2;
1562  Bool_t spdfirst = (itsmap & bit1) == bit1;
1563  Bool_t spdsecond = (itsmap & bit2) == bit2;
1564  fCandidateEleVariables[10] = ((Int_t)spdfirst) + 2 * ((Int_t)spdsecond);
1565 
1566  if(fAnalCuts->GetIsUsePID())
1567  {
1568  Double_t nSigmaTPCele = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kElectron);
1569  Double_t nSigmaTOFele = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(trk,AliPID::kElectron);
1570  Double_t nSigmaTPCpi_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kPion);
1571  Double_t nSigmaTPCka_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kKaon);
1572  Double_t nSigmaTPCpr_etrk = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kProton);
1573  fCandidateEleVariables[11] = nSigmaTPCele;
1574  fCandidateEleVariables[12] = nSigmaTOFele;
1575  fCandidateEleVariables[13] = nSigmaTPCpi_etrk;
1576  fCandidateEleVariables[14] = nSigmaTPCka_etrk;
1577  fCandidateEleVariables[15] = nSigmaTPCpr_etrk;
1578  }
1580  fCandidateEleVariables[17] = trk->Charge();
1581  fCandidateEleVariables[18] = pdgEle;
1582  fCandidateEleVariables[19] = pdgEleMother;
1583  fCandidateEleVariables[20] = mcepx;
1584  fCandidateEleVariables[21] = mcepy;
1585  fCandidateEleVariables[22] = mcepz;
1588 
1589  fHistod0Bach->Fill(d0z0[0]);
1590 
1591  fEleVariablesTree->Fill();
1592 }
1595 {
1596  //
1597  // Define V0 tree variables
1598  //
1599 
1600  const char* nameoutput = GetOutputSlot(6)->GetContainer()->GetName();
1601  fCascVariablesTree = new TTree(nameoutput,"cascade variables tree");
1602  Int_t nVar = 24;
1603  fCandidateCascVariables = new Float_t [nVar];
1604  TString * fCandidateVariableNames = new TString[nVar];
1605 
1606  fCandidateVariableNames[ 0]="Centrality";
1607  fCandidateVariableNames[ 1]="InvMassXi";
1608  fCandidateVariableNames[ 2]="XiPx";
1609  fCandidateVariableNames[ 3]="XiPy";
1610  fCandidateVariableNames[ 4]="XiPz";
1611  fCandidateVariableNames[ 5]="InvMassLambda";
1612  fCandidateVariableNames[ 6]="DcaXiDaughters";
1613  fCandidateVariableNames[ 7]="DcaV0Daughters";
1614  fCandidateVariableNames[ 8]="DecayLengthXi";
1615  fCandidateVariableNames[ 9]="CosPointingAngleXi";
1616  fCandidateVariableNames[10]="DcaV0toPrimVertex";
1617  fCandidateVariableNames[11]="DcaPostoPrimVertex";
1618  fCandidateVariableNames[12]="DcaNegtoPrimVertex";
1619  fCandidateVariableNames[13]="DcaBachtoPrimVertex";
1620  fCandidateVariableNames[14]="DecayLengthV0";
1621  fCandidateVariableNames[15]="CosPointingAngleV0";
1622  fCandidateVariableNames[16]="XiCharge";
1623  fCandidateVariableNames[17]="XiPdgCode";
1624  fCandidateVariableNames[18]="XiMotherPdgCode";
1625  fCandidateVariableNames[19]="mcxipx";
1626  fCandidateVariableNames[20]="mcxipy";
1627  fCandidateVariableNames[21]="mcxipz";
1628  fCandidateVariableNames[22]="RunNumber";
1629  fCandidateVariableNames[23]="EvNumber";
1630 
1631  for (Int_t ivar=0; ivar<nVar; ivar++) {
1632  fCascVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateCascVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
1633  }
1634 
1635  return;
1636 }
1637 
1639 void AliAnalysisTaskSEXic2eleXifromAODtracks::FillCascROOTObjects(AliAODcascade *casc, TClonesArray *mcArray)
1640 {
1641  //
1642  // Fill histograms or tree depending on fWriteVariableTree (tree not implemented yet)
1643  //
1644  if(!casc) return;
1645  fHistoXiMassvsPt->Fill(casc->MassXi(),sqrt(casc->MomXiX()*casc->MomXiX()+casc->MomXiY()*casc->MomXiY()));
1646  fHistoOmegaMassvsPt->Fill(casc->MassOmega(),sqrt(casc->MomXiX()*casc->MomXiX()+casc->MomXiY()*casc->MomXiY()));
1647  Double_t momxix = casc->MomXiX();
1648  Double_t momxiy = casc->MomXiY();
1649  Double_t phi_alice = atan2(momxiy,momxix);
1650  if(phi_alice<0.) phi_alice += 2 * M_PI;
1651  fHistoXiQovPtvsPhi->Fill(phi_alice,(Double_t)casc->ChargeXi()/sqrt(momxix*momxix+momxiy*momxiy));
1652 
1653  Int_t xipdgcode = -9999;
1654  Int_t ximotherpdgcode = -9999;
1655  Float_t mcxipx = -9999.;
1656  Float_t mcxipy = -9999.;
1657  Float_t mcxipz = -9999.;
1658  if(fUseMCInfo){
1659  Int_t pdgDgcasc[2]={211,3122};
1660  Int_t pdgDgv0[2]={2212,211};
1661  Int_t labcasc = MatchToMCCascade(casc,3312,pdgDgcasc,pdgDgv0,mcArray); // the cascade
1662  if(labcasc<0) return;
1663 
1664  fHistoXiMassvsPtMCS->Fill(casc->MassXi(),sqrt(casc->MomXiX()*casc->MomXiX()+casc->MomXiY()*casc->MomXiY()));
1665 
1666  AliAODMCParticle *mccasctrk = (AliAODMCParticle*)mcArray->At(labcasc);
1667  if(!mccasctrk) return;
1668 
1669  Bool_t hfxi_flag = kFALSE;
1670  xipdgcode = mccasctrk->GetPdgCode();
1671  Int_t labcascmother = mccasctrk->GetMother();
1672  if(labcascmother>=0){
1673  AliAODMCParticle *mothercasc = (AliAODMCParticle*)mcArray->At(labcascmother);
1674  if(mothercasc){
1675  ximotherpdgcode = mothercasc->GetPdgCode();
1676  if(abs(ximotherpdgcode)>4000&&abs(ximotherpdgcode)<4400){
1677  hfxi_flag = kTRUE;
1678  }
1679  }
1680  }
1681  if(!hfxi_flag) return;
1682  mcxipx = mccasctrk->Px();
1683  mcxipy = mccasctrk->Py();
1684  mcxipz = mccasctrk->Pz();
1685  }
1686 
1687  if(!fWriteEachVariableTree) return;
1688 
1689 
1690  for(Int_t i=0;i<24;i++){
1691  fCandidateCascVariables[i] = -9999.;
1692  }
1693  Double_t posVtx[3] = {0.,0.,0.};
1694  fVtx1->GetXYZ(posVtx);
1695 
1697  fCandidateCascVariables[ 1] = casc->MassXi();
1698  fCandidateCascVariables[ 2] = casc->MomXiX();
1699  fCandidateCascVariables[ 3] = casc->MomXiY();
1700  fCandidateCascVariables[ 4] = casc->MomXiZ();
1701  if(casc->ChargeXi()<0)
1702  fCandidateCascVariables[ 5] = casc->MassLambda();
1703  else
1704  fCandidateCascVariables[ 5] = casc->MassAntiLambda();
1705 
1706  fCandidateCascVariables[ 6] = casc->DcaXiDaughters();
1707  fCandidateCascVariables[ 7] = casc->DcaV0Daughters();
1708  fCandidateCascVariables[ 8] = casc->DecayLengthXi(posVtx[0],posVtx[1],posVtx[2]);
1709  fCandidateCascVariables[ 9] = casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
1710  fCandidateCascVariables[10] = casc->DcaV0ToPrimVertex();
1711  fCandidateCascVariables[11] = casc->DcaPosToPrimVertex();
1712  fCandidateCascVariables[12] = casc->DcaNegToPrimVertex();
1713  fCandidateCascVariables[13] = casc->DcaBachToPrimVertex();
1714  fCandidateCascVariables[14] = casc->DecayLengthV0();
1715  fCandidateCascVariables[15] = casc->CosPointingAngle(casc->GetDecayVertexXi());
1716  fCandidateCascVariables[16] = casc->ChargeXi();
1717  fCandidateCascVariables[17] = xipdgcode;
1718  fCandidateCascVariables[18] = ximotherpdgcode;
1719  fCandidateCascVariables[19] = mcxipx;
1720  fCandidateCascVariables[20] = mcxipy;
1721  fCandidateCascVariables[21] = mcxipz;
1724 
1725  fCascVariablesTree->Fill();
1726 }
1729 {
1730  //
1731  // Define electron tree variables
1732  //
1733 
1734  const char* nameoutput = GetOutputSlot(7)->GetContainer()->GetName();
1735  fMCVariablesTree = new TTree(nameoutput,"MC variables tree");
1736  Int_t nVar = 16;
1737  fCandidateMCVariables = new Float_t [nVar];
1738  TString * fCandidateVariableNames = new TString[nVar];
1739 
1740  fCandidateVariableNames[ 0]="Centrality";
1741  fCandidateVariableNames[ 1]="DecayType";
1742  fCandidateVariableNames[ 2]="XicPx";
1743  fCandidateVariableNames[ 3]="XicPy";
1744  fCandidateVariableNames[ 4]="XicPz";
1745  fCandidateVariableNames[ 5]="ElePx";
1746  fCandidateVariableNames[ 6]="ElePy";
1747  fCandidateVariableNames[ 7]="ElePz";
1748  fCandidateVariableNames[ 8]="CascPx";
1749  fCandidateVariableNames[ 9]="CascPy";
1750  fCandidateVariableNames[10]="CascPz";
1751  fCandidateVariableNames[11]="PdgCode";
1752  fCandidateVariableNames[12]="ElePdgCode";
1753  fCandidateVariableNames[13]="CascPdgCode";
1754  fCandidateVariableNames[14]="RunNumber";
1755  fCandidateVariableNames[15]="EvNumber";
1756 
1757  for (Int_t ivar=0; ivar<nVar; ivar++) {
1758  fMCVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateMCVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
1759  }
1760  return;
1761 }
1763 void AliAnalysisTaskSEXic2eleXifromAODtracks::FillMCROOTObjects(AliAODMCParticle *mcpart, AliAODMCParticle *mcepart, AliAODMCParticle *mccascpart, Int_t decaytype)
1764 {
1765  //
1766  // Fill histograms or tree depending on fWriteMCVariableTree
1767  //
1768  if(!mcpart) return;
1769  if(!mcepart) return;
1770  if(!mccascpart) return;
1771 
1772  for(Int_t i=0;i<14;i++){
1773  fCandidateMCVariables[i] = -9999.;
1774  }
1775 
1777  fCandidateMCVariables[ 1] = decaytype;
1778  fCandidateMCVariables[ 2] = mcpart->Px();
1779  fCandidateMCVariables[ 3] = mcpart->Py();
1780  fCandidateMCVariables[ 4] = mcpart->Pz();
1781  fCandidateMCVariables[ 5] = mcepart->Px();
1782  fCandidateMCVariables[ 6] = mcepart->Py();
1783  fCandidateMCVariables[ 7] = mcepart->Pz();
1784  fCandidateMCVariables[ 8] = mccascpart->Px();
1785  fCandidateMCVariables[ 9] = mccascpart->Py();
1786  fCandidateMCVariables[10] = mccascpart->Pz();
1787  fCandidateMCVariables[11] = mcpart->GetPdgCode();
1788  fCandidateMCVariables[12] = mcepart->GetPdgCode();
1789  fCandidateMCVariables[13] = mccascpart->GetPdgCode();
1792 
1793  Double_t epx = mcepart->Px();
1794  Double_t epy = mcepart->Py();
1795  Double_t epz = mcepart->Pz();
1796  Double_t eE = sqrt(epx*epx+epy*epy+epz*epz+0.000511*0.000511);
1797  Double_t cascpx = mccascpart->Px();
1798  Double_t cascpy = mccascpart->Py();
1799  Double_t cascpz = mccascpart->Pz();
1800  Double_t cascE = sqrt(cascpx*cascpx+cascpy*cascpy+cascpz*cascpz+1.32171*1.32171);
1801 
1802  Double_t InvMassEleXi = sqrt(pow(eE+cascE,2)-pow(epx+cascpx,2)-pow(epy+cascpy,2)-pow(epz+cascpz,2));
1803 
1804  Double_t cont[3];
1805  cont[0] = InvMassEleXi;
1806  cont[1] = mcpart->Pt();
1807  cont[2] = fCentrality;
1808  Double_t cont2[3];
1809  cont2[0] = InvMassEleXi;
1810  cont2[1] = mcepart->Pt();
1811  cont2[2] = fCentrality;
1812  Double_t cont_eleptvseta[3];
1813  cont_eleptvseta[0] = mcepart->Pt();
1814  cont_eleptvseta[1] = mcepart->Eta();
1815  cont_eleptvseta[2] = fCentrality;
1816  Double_t cont_eleptvsxipt[3];
1817  cont_eleptvsxipt[0] = mcepart->Pt();
1818  cont_eleptvsxipt[1] = mccascpart->Pt();
1819  cont_eleptvsxipt[2] = fCentrality;
1820  Double_t cont_eleptvsxiptvsxicpt[4];
1821  cont_eleptvsxiptvsxicpt[0] = mcepart->Pt();
1822  cont_eleptvsxiptvsxicpt[1] = mccascpart->Pt();
1823  cont_eleptvsxiptvsxicpt[2] = mcpart->Pt();
1824  cont_eleptvsxiptvsxicpt[3] = fCentrality;
1825 
1826  Double_t contmc[3];
1827  contmc[0] = mcpart->Pt();
1828  contmc[1] = mcpart->Y();
1829  contmc[2] = fCentrality;
1830  Double_t contmcele[3];
1831  contmcele[0] = mcepart->Pt();
1832  contmcele[1] = mcepart->Eta();
1833  contmcele[2] = fCentrality;
1834 
1835 
1836  AliESDtrackCuts *esdcuts = fAnalCuts->GetTrackCuts();
1837  Float_t etamin, etamax;
1838  esdcuts->GetEtaRange(etamin,etamax);
1839 
1840  if(decaytype==0){
1841  fHistoXicMCGen->Fill(contmc);
1842  fHistoXicElectronMCGen->Fill(contmcele);
1843  fHistoEleXiMassMCGen->Fill(cont);
1844  if(fabs(mcepart->Eta())<etamax){
1845  fHistoEleXiMassvsElePtMCGen->Fill(cont2);
1846  if(InvMassEleXi<2.5){
1847  fHistoElePtMCGen->Fill(mcepart->Pt(),fCentrality);
1848  fHistoElePtvsEtaMCGen->Fill(cont_eleptvseta);
1849  fHistoElePtvsXiPtMCGen->Fill(cont_eleptvsxipt);
1850  }
1851  }
1852  if(fabs(mcpart->Y())<0.7){
1853  if(InvMassEleXi<2.5){
1854  fHistoElePtvsXiPtMCXicGen->Fill(cont_eleptvsxipt);
1855  fHistoElePtvsXiPtvsXicPtMCGen->Fill(cont_eleptvsxiptvsxicpt);
1856  }
1857  }
1858  }
1859 
1861  fMCVariablesTree->Fill();
1862 }
1865 {
1866  //
1867  // Define mc gen electron tree variables
1868  //
1869 
1870  const char* nameoutput = GetOutputSlot(9)->GetContainer()->GetName();
1871  fMCEleVariablesTree = new TTree(nameoutput,"MC Ele variables tree");
1872  Int_t nVar = 8;
1873  fCandidateMCEleVariables = new Float_t [nVar];
1874  TString * fCandidateVariableNames = new TString[nVar];
1875 
1876  fCandidateVariableNames[ 0]="Centrality";
1877  fCandidateVariableNames[ 1]="ElePx";
1878  fCandidateVariableNames[ 2]="ElePy";
1879  fCandidateVariableNames[ 3]="ElePz";
1880  fCandidateVariableNames[ 4]="ElePdgCode";
1881  fCandidateVariableNames[ 5]="EleMotherPdgCode";
1882  fCandidateVariableNames[ 6]="RunNumber";
1883  fCandidateVariableNames[ 7]="EvNumber";
1884 
1885  for (Int_t ivar=0; ivar<nVar; ivar++) {
1886  fMCEleVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateMCEleVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
1887  }
1888  return;
1889 }
1891 void AliAnalysisTaskSEXic2eleXifromAODtracks::FillMCEleROOTObjects(AliAODMCParticle *mcepart, TClonesArray *mcArray)
1892 {
1893  //
1894  // Fill tree depending on fWriteMCVariableTree
1895  //
1896  if(!mcepart) return;
1897 
1898 
1899  Bool_t hfe_flag = kFALSE;
1900  Int_t labemother = mcepart->GetMother();
1901  Int_t pdgmotherele = -9999;
1902  if(labemother>=0){
1903  AliAODMCParticle *motherele = (AliAODMCParticle*)mcArray->At(labemother);
1904  pdgmotherele = motherele->GetPdgCode();
1905  if(abs(pdgmotherele)>4000&&abs(pdgmotherele)<4400){
1906  hfe_flag = kTRUE;
1907  }
1908  }
1909  if(!hfe_flag) return;
1910 
1911  Double_t contmc[3];
1912  contmc[0] = mcepart->Pt();
1913  contmc[1] = mcepart->Eta();
1914  contmc[2] = fCentrality;
1915  fHistoElectronMCGen->Fill(contmc);
1916 
1917  for(Int_t i=0;i<8;i++){
1918  fCandidateMCEleVariables[i] = -9999.;
1919  }
1920 
1922  fCandidateMCEleVariables[ 1] = mcepart->Px();
1923  fCandidateMCEleVariables[ 2] = mcepart->Py();
1924  fCandidateMCEleVariables[ 3] = mcepart->Pz();
1925  fCandidateMCEleVariables[ 4] = mcepart->GetPdgCode();
1926  fCandidateMCEleVariables[ 5] = pdgmotherele;
1929 
1930  // This function makes output too heavy (do not use if you have output size limitation)
1931  //if(fWriteMCVariableTree && fWriteEachVariableTree && mcepart->Pt()>0.4 && fabs(mcepart->Eta())<1.0)
1932  //fMCEleVariablesTree->Fill();
1933 }
1936 {
1937  //
1938  // Define Mc cascade tree variables
1939  //
1940 
1941  const char* nameoutput = GetOutputSlot(10)->GetContainer()->GetName();
1942  fMCCascVariablesTree = new TTree(nameoutput,"MC cascade variables tree");
1943  Int_t nVar = 8;
1944  fCandidateMCCascVariables = new Float_t [nVar];
1945  TString * fCandidateVariableNames = new TString[nVar];
1946 
1947  fCandidateVariableNames[ 0]="Centrality";
1948  fCandidateVariableNames[ 1]="CascPx";
1949  fCandidateVariableNames[ 2]="CascPy";
1950  fCandidateVariableNames[ 3]="CascPz";
1951  fCandidateVariableNames[ 4]="CascPdgCode";
1952  fCandidateVariableNames[ 5]="CascMotherPdgCode";
1953  fCandidateVariableNames[ 6]="RunNumber";
1954  fCandidateVariableNames[ 7]="EvNumber";
1955 
1956  for (Int_t ivar=0; ivar<nVar; ivar++) {
1957  fMCCascVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateMCCascVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
1958  }
1959  return;
1960 }
1962 void AliAnalysisTaskSEXic2eleXifromAODtracks::FillMCCascROOTObjects(AliAODMCParticle *mccascpart, TClonesArray *mcArray)
1963 {
1964  //
1965  // Fill histograms or tree depending on fWriteMCVariableTree
1966  //
1967  if(!mccascpart) return;
1968 
1969  for(Int_t i=0;i<8;i++){
1970  fCandidateMCCascVariables[i] = -9999.;
1971  }
1972 
1973  Bool_t hfxi_flag = kFALSE;
1974  Int_t labcascmother = mccascpart->GetMother();
1975  Int_t pdgmothercasc = -9999;
1976  if(labcascmother>=0){
1977  AliAODMCParticle *mothercasc = (AliAODMCParticle*)mcArray->At(labcascmother);
1978  if(mothercasc){
1979  pdgmothercasc = mothercasc->GetPdgCode();
1980  if(abs(pdgmothercasc)>4000&&abs(pdgmothercasc)<4400){
1981  hfxi_flag = kTRUE;
1982  }
1983  }
1984  }
1985  if(!hfxi_flag) return;
1986 
1987  Double_t contmc[3];
1988  contmc[0] = mccascpart->Pt();
1989  contmc[1] = mccascpart->Eta();
1990  contmc[2] = fCentrality;
1991  fHistoXiMCGen->Fill(contmc);
1992 
1994  fCandidateMCCascVariables[ 1] = mccascpart->Px();
1995  fCandidateMCCascVariables[ 2] = mccascpart->Py();
1996  fCandidateMCCascVariables[ 3] = mccascpart->Pz();
1997  fCandidateMCCascVariables[ 4] = mccascpart->GetPdgCode();
1998  fCandidateMCCascVariables[ 5] = pdgmothercasc;
2001 
2002  // This function makes output too heavy (do not use if you have output size limitation)
2003  //if(fWriteMCVariableTree && fWriteEachVariableTree && mccascpart->Pt()>0.4 && fabs(mccascpart->Eta())<1.0)
2004  //fMCCascVariablesTree->Fill();
2005 }
2006 
2009  //
2010  // This is to define general histograms
2011  //
2012 
2013  fCEvents = new TH1F("fCEvents","conter",18,-0.5,17.5);
2014  fCEvents->SetStats(kTRUE);
2015  fCEvents->GetXaxis()->SetBinLabel(1,"X1");
2016  fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
2017  fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
2018  fCEvents->GetXaxis()->SetBinLabel(4,"TriggerOK");
2019  fCEvents->GetXaxis()->SetBinLabel(5,"IsEventSelected");
2020  fCEvents->GetXaxis()->SetBinLabel(6,"CascadesHF exists");
2021  fCEvents->GetXaxis()->SetBinLabel(7,"MCarray exists");
2022  fCEvents->GetXaxis()->SetBinLabel(8,"MCheader exists");
2023  fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
2024  fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
2025  fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
2026  fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
2027  fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
2028  fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
2029  fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
2030  fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
2031  fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
2032  fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
2033  //fCEvents->GetXaxis()->SetTitle("");
2034  fCEvents->GetYaxis()->SetTitle("counts");
2035 
2036  fHTrigger = new TH1F("fHTrigger","counter",18,-0.5,17.5);
2037  fHTrigger->SetStats(kTRUE);
2038  fHTrigger->GetXaxis()->SetBinLabel(1,"X1");
2039  fHTrigger->GetXaxis()->SetBinLabel(2,"kMB");
2040  fHTrigger->GetXaxis()->SetBinLabel(3,"kSemiCentral");
2041  fHTrigger->GetXaxis()->SetBinLabel(4,"kCentral");
2042  fHTrigger->GetXaxis()->SetBinLabel(5,"kINT7");
2043  fHTrigger->GetXaxis()->SetBinLabel(6,"kEMC7");
2044  //fHTrigger->GetXaxis()->SetBinLabel(7,"Space");
2045  fHTrigger->GetXaxis()->SetBinLabel(8,"kMB|kSemiCentral|kCentral");
2046  fHTrigger->GetXaxis()->SetBinLabel(9,"kINT7|kEMC7");
2047  fHTrigger->GetXaxis()->SetBinLabel(11,"kMB&kSemiCentral");
2048  fHTrigger->GetXaxis()->SetBinLabel(12,"kMB&kCentral");
2049  fHTrigger->GetXaxis()->SetBinLabel(13,"kINT7&kEMC7");
2050 
2051  fHCentrality = new TH1F("fHCentrality","conter",100,0.,100.);
2052 
2053 
2054  fOutput->Add(fCEvents);
2055  fOutput->Add(fHTrigger);
2056  fOutput->Add(fHCentrality);
2057 
2058  return;
2059 }
2060 //__________________________________________________________________________
2062 {
2063  //
2064  // Define analyis histograms
2065  //
2066 
2067  //------------------------------------------------
2068  // Basic histogram
2069  //------------------------------------------------
2070  Int_t bins_base[3]= {16 ,100 ,10};
2071  Double_t xmin_base[3]={1.3,0 ,0.00};
2072  Double_t xmax_base[3]={3.3,10. ,100};
2073 
2074  fHistoEleXiMass = new THnSparseF("fHistoEleXiMass","",3,bins_base,xmin_base,xmax_base);
2076  fHistoEleXiMassRS = new THnSparseF("fHistoEleXiMassRS","",3,bins_base,xmin_base,xmax_base);
2078  fHistoEleXiMassWS = new THnSparseF("fHistoEleXiMassWS","",3,bins_base,xmin_base,xmax_base);
2080  fHistoEleXiMassRSMix = new THnSparseF("fHistoEleXiMassRSMix","",3,bins_base,xmin_base,xmax_base);
2082  fHistoEleXiMassWSMix = new THnSparseF("fHistoEleXiMassWSMix","",3,bins_base,xmin_base,xmax_base);
2084 
2085  fHistoEleXiMassvsElePtRS = new THnSparseF("fHistoEleXiMassvsElePtRS","",3,bins_base,xmin_base,xmax_base);
2087  fHistoEleXiMassvsElePtWS = new THnSparseF("fHistoEleXiMassvsElePtWS","",3,bins_base,xmin_base,xmax_base);
2089  fHistoEleXiMassvsElePtRSMix = new THnSparseF("fHistoEleXiMassvsElePtRSMix","",3,bins_base,xmin_base,xmax_base);
2091  fHistoEleXiMassvsElePtWSMix = new THnSparseF("fHistoEleXiMassvsElePtWSMix","",3,bins_base,xmin_base,xmax_base);
2093 
2094  fHistoElePtRS=new TH2F("fHistoElePtRS","Right-sign e pt",100,0.,10.,10,0.,100.);
2095  fOutputAll->Add(fHistoElePtRS);
2096  fHistoElePtWS=new TH2F("fHistoElePtWS","Wrong-sign e pt",100,0.,10.,10,0.,100.);
2097  fOutputAll->Add(fHistoElePtWS);
2098  fHistoElePtRSMix=new TH2F("fHistoElePtRSMix","Right-sign e pt",100,0.,10.,10,0.,100.);
2100  fHistoElePtWSMix=new TH2F("fHistoElePtWSMix","Wrong-sign e pt",100,0.,10.,10,0.,100.);
2102 
2103  fHistoEleXiMassMCS = new THnSparseF("fHistoEleXiMassMCS","",3,bins_base,xmin_base,xmax_base);
2105  fHistoEleXiMassMCGen = new THnSparseF("fHistoEleXiMassMCGen","",3,bins_base,xmin_base,xmax_base);
2107  fHistoEleXiMassvsElePtMCS = new THnSparseF("fHistoEleXiMassvsElePtMCS","",3,bins_base,xmin_base,xmax_base);
2109  fHistoEleXiMassvsElePtMCGen = new THnSparseF("fHistoEleXiMassvsElePtMCGen","",3,bins_base,xmin_base,xmax_base);
2111  fHistoElePtMCS=new TH2F("fHistoElePtMCS","MC S e pt",100,0.,10.,10,0.,100.);
2112  fOutputAll->Add(fHistoElePtMCS);
2113  fHistoElePtMCGen=new TH2F("fHistoElePtMCGen","MC Gen e pt",100,0.,10.,10,0.,100.);
2115 
2116  Int_t bins_eleptvseta[3]= {50,20 ,10};
2117  Double_t xmin_eleptvseta[3]={0.,-1. ,0.0};
2118  Double_t xmax_eleptvseta[3]={5.,1. ,100};
2119 
2120  fHistoElePtvsEtaRS = new THnSparseF("fHistoElePtvsEtaRS","",3,bins_eleptvseta,xmin_eleptvseta,xmax_eleptvseta);
2122  fHistoElePtvsEtaWS = new THnSparseF("fHistoElePtvsEtaWS","",3,bins_eleptvseta,xmin_eleptvseta,xmax_eleptvseta);
2124  fHistoElePtvsEtaRSMix = new THnSparseF("fHistoElePtvsEtaRSMix","",3,bins_eleptvseta,xmin_eleptvseta,xmax_eleptvseta);
2126  fHistoElePtvsEtaWSMix = new THnSparseF("fHistoElePtvsEtaWSMix","",3,bins_eleptvseta,xmin_eleptvseta,xmax_eleptvseta);
2128  fHistoElePtvsEtaMCS = new THnSparseF("fHistoElePtvsEtaMCS","",3,bins_eleptvseta,xmin_eleptvseta,xmax_eleptvseta);
2130  fHistoElePtvsEtaMCGen = new THnSparseF("fHistoElePtvsEtaMCGen","",3,bins_eleptvseta,xmin_eleptvseta,xmax_eleptvseta);
2132 
2133  Int_t bins_eleptvsxipt[3]= {50,20 ,10};
2134  Double_t xmin_eleptvsxipt[3]={0.,0. ,0.0};
2135  Double_t xmax_eleptvsxipt[3]={5.,5. ,100};
2136 
2137  fHistoElePtvsXiPtRS = new THnSparseF("fHistoElePtvsXiPtRS","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2139  fHistoElePtvsXiPtWS = new THnSparseF("fHistoElePtvsXiPtWS","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2141  fHistoElePtvsXiPtRSMix = new THnSparseF("fHistoElePtvsXiPtRSMix","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2143  fHistoElePtvsXiPtWSMix = new THnSparseF("fHistoElePtvsXiPtWSMix","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2145  fHistoElePtvsXiPtMCS = new THnSparseF("fHistoElePtvsXiPtMCS","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2147  fHistoElePtvsXiPtMCGen = new THnSparseF("fHistoElePtvsXiPtMCGen","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2149  fHistoElePtvsXiPtMCXicGen = new THnSparseF("fHistoElePtvsXiPtMCXicGen","",3,bins_eleptvsxipt,xmin_eleptvsxipt,xmax_eleptvsxipt);
2151 
2152  Int_t bins_eleptvsxiptvsxicpt[4]= {50,20,10,10};
2153  Double_t xmin_eleptvsxiptvsxicpt[4]={0.,0.,0.,0.0};
2154  Double_t xmax_eleptvsxiptvsxicpt[4]={5.,5.,10.,100};
2155  fHistoElePtvsXiPtvsXicPtMCS = new THnSparseF("fHistoElePtvsXiPtvsXicPtMCS","",4,bins_eleptvsxiptvsxicpt,xmin_eleptvsxiptvsxicpt,xmax_eleptvsxiptvsxicpt);
2157  fHistoElePtvsXiPtvsXicPtMCGen = new THnSparseF("fHistoElePtvsXiPtvsXicPtMCGen","",4,bins_eleptvsxiptvsxicpt,xmin_eleptvsxiptvsxicpt,xmax_eleptvsxiptvsxicpt);
2159 
2160  Int_t bins_eleptvsd0[3]= {50 ,50 ,10};
2161  Double_t xmin_eleptvsd0[3]={0.,-0.2 ,0.0};
2162  Double_t xmax_eleptvsd0[3]={5.,0.2 ,100};
2163 
2164  fHistoElePtvsd0RS = new THnSparseF("fHistoElePtvsd0RS","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2166  fHistoElePtvsd0WS = new THnSparseF("fHistoElePtvsd0WS","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2168  fHistoElePtvsd0RSMix = new THnSparseF("fHistoElePtvsd0RSMix","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2170  fHistoElePtvsd0WSMix = new THnSparseF("fHistoElePtvsd0WSMix","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2172  fHistoElePtvsd0MCS = new THnSparseF("fHistoElePtvsd0MCS","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2174  fHistoElePtvsd0PromptMCS = new THnSparseF("fHistoElePtvsd0PromptMCS","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2176  fHistoElePtvsd0BFeeddownMCS = new THnSparseF("fHistoElePtvsd0BFeeddownMCS","",3,bins_eleptvsd0,xmin_eleptvsd0,xmax_eleptvsd0);
2178 
2179  //------------------------------------------------
2180  // checking histograms
2181  //------------------------------------------------
2182  fHistoBachPt = new TH1F("fHistoBachPt","Bachelor p_{T}",100,0.0,5.0);
2183  fOutputAll->Add(fHistoBachPt);
2184  fHistoBachPtMCS = new TH1F("fHistoBachPtMCS","Bachelor p_{T}",100,0.0,5.0);
2186  fHistoBachPtMCGen = new TH1F("fHistoBachPtMCGen","Bachelor p_{T}",100,0.0,5.0);
2188  fHistod0Bach = new TH1F("fHistod0Bach","Bachelor d_{0}",100,-0.5,0.5);
2189  fOutputAll->Add(fHistod0Bach);
2190  fHistoXiMassvsPt=new TH2F("fHistoXiMassvsPt","Xi mass",100,1.32-0.05,1.32+0.05,20,0.,10.);
2192  fHistoXiMassvsPtMCS=new TH2F("fHistoXiMassvsPtMCS","Xi mass",100,1.32-0.05,1.32+0.05,20,0.,10.);
2194  fHistoXiMassvsPtMCGen=new TH2F("fHistoXiMassvsPtMCGen","Xi mass",100,1.32-0.05,1.32+0.05,20,0.,10.);
2196  fHistoOmegaMassvsPt=new TH2F("fHistoOmegaMassvsPt","Omega mass",100,1.67-0.05,1.67+0.05,20,0.,10.);
2198 
2199  fHistoElectronTPCPID=new TH2F("fHistoElectronTPCPID","",50,0.,5.,50,-20.,20.);
2201  fHistoElectronTOFPID=new TH2F("fHistoElectronTOFPID","",50,0.,5.,50,-20.,20.);
2203  fHistoElectronTPCSelPID=new TH2F("fHistoElectronTPCSelPID","",50,0.,5.,50,-20.,20.);
2205  fHistoElectronTOFSelPID=new TH2F("fHistoElectronTOFSelPID","",50,0.,5.,50,-20.,20.);
2207  fHistoElectronTPCPIDSelTOF=new TH2F("fHistoElectronTPCPIDSelTOF","",10,0.,5.,500,-10.,10.);
2209  fHistoElectronTPCPIDSelTOFSmallEta=new TH2F("fHistoElectronTPCPIDSelTOFSmallEta","",10,0.,5.,500,-10.,10.);
2211  fHistoElectronTPCPIDSelTOFLargeEta=new TH2F("fHistoElectronTPCPIDSelTOFLargeEta","",10,0.,5.,500,-10.,10.);
2213 
2214  for(Int_t i=0;i<8;i++){
2215  fHistoElectronTPCPIDSelTOFEtaDep[i]=new TH2F(Form("fHistoElectronTPCPIDSelTOFEtaDep[%d]",i),"",10,0.,5.,500,-10.,10.);
2217  }
2218 
2219  fHistoElectronQovPtvsPhi=new TH2F("fHistoElectronQovPtvsPhi","",70,0.,7.,50,-2.,2.);
2221  fHistoXiQovPtvsPhi=new TH2F("fHistoXiQovPtvsPhi","",70,0.,7.,50,-2.,2.);
2223 
2224  Int_t bins_xicmcgen[3]= {40 ,20 ,10};
2225  Double_t xmin_xicmcgen[3]={0.,-1.0 ,0.0};
2226  Double_t xmax_xicmcgen[3]={20.,1.0 ,100};
2227  fHistoXicMCGen = new THnSparseF("fHistoXicMCGen","",3,bins_xicmcgen,xmin_xicmcgen,xmax_xicmcgen);
2228  fOutputAll->Add(fHistoXicMCGen);
2229 
2230  Int_t bins_elemcgen[3]= {60 ,20 ,10};
2231  Double_t xmin_elemcgen[3]={0.,-1.0 ,0.0};
2232  Double_t xmax_elemcgen[3]={6.,1.0 ,100};
2233  fHistoElectronMCGen = new THnSparseF("fHistoElectronMCGen","",3,bins_elemcgen,xmin_elemcgen,xmax_elemcgen);
2235  fHistoXicElectronMCGen = new THnSparseF("fHistoXicElectronMCGen","",3,bins_elemcgen,xmin_elemcgen,xmax_elemcgen);
2237 
2238  Int_t bins_ximcgen[3]= {50 ,20 ,10};
2239  Double_t xmin_ximcgen[3]={0.,-1.0 ,0.0};
2240  Double_t xmax_ximcgen[3]={10.,1.0 ,100};
2241  fHistoXiMCGen = new THnSparseF("fHistoXiMCGen","",3,bins_ximcgen,xmin_ximcgen,xmax_ximcgen);
2242  fOutputAll->Add(fHistoXiMCGen);
2243 
2244  fHistonEvtvsRunNumber=new TH1F("fHistonEvtvsRunNumber","",20000,-0.5,19999.5);
2246  fHistonElevsRunNumber=new TH1F("fHistonElevsRunNumber","",20000,-0.5,19999.5);
2248  fHistonXivsRunNumber=new TH1F("fHistonXivsRunNumber","",20000,-0.5,19999.5);
2250 
2251  for(Int_t ih=0;ih<23;ih++){
2252  Int_t bins_eleptvscutvars[3];
2253  Double_t xmin_eleptvscutvars[3];
2254  Double_t xmax_eleptvscutvars[3];
2255 
2256  bins_eleptvscutvars[0] = 50;//electron pT bin
2257  xmin_eleptvscutvars[0] = 0.;
2258  xmax_eleptvscutvars[0] = 5.;
2259  bins_eleptvscutvars[2] = 10;//centrality bin
2260  xmin_eleptvscutvars[2] = 0.;
2261  xmax_eleptvscutvars[2] = 100.;
2262 
2263  if(ih==0 || ih==1){
2264  //0: TPC Ncluster 1: TPC ncluster PID
2265  bins_eleptvscutvars[1] = 40;
2266  xmin_eleptvscutvars[1] = 0.;
2267  xmax_eleptvscutvars[1] = 160.;
2268  }else if(ih==2 || ih==3){
2269  //2: nSigma(TPC,e) 3: nSigma(TOF,e)
2270  bins_eleptvscutvars[1] = 20;
2271  xmin_eleptvscutvars[1] = -5.;
2272  xmax_eleptvscutvars[1] = 5.;
2273  }else if(ih==4){
2274  //4: eta
2275  bins_eleptvscutvars[1] = 30;
2276  xmin_eleptvscutvars[1] = -1.5;
2277  xmax_eleptvscutvars[1] = 1.5;
2278  }else if(ih==5){
2279  //5: nITS cluster
2280  bins_eleptvscutvars[1] = 7;
2281  xmin_eleptvscutvars[1] = -0.5;
2282  xmax_eleptvscutvars[1] = 6.5;
2283  }else if(ih==6){
2284  //6: Lambda mass
2285  bins_eleptvscutvars[1] = 50;
2286  xmin_eleptvscutvars[1] = 1.1156-0.03;
2287  xmax_eleptvscutvars[1] = 1.1156+0.03;
2288  }else if(ih==7){
2289  //7: Xi mass
2290  bins_eleptvscutvars[1] = 50;
2291  xmin_eleptvscutvars[1] = 1.32-0.03;
2292  xmax_eleptvscutvars[1] = 1.32+0.03;
2293  }else if(ih==8 || ih==9){
2294  //8: Rfid Lambda, 9: Rfid Xi
2295  bins_eleptvscutvars[1] = 20;
2296  xmin_eleptvscutvars[1] = 0.;
2297  xmax_eleptvscutvars[1] = 5.;
2298  }else if(ih==10 || ih==11){
2299  //11: DCA Xi, 10: Dca V0
2300  bins_eleptvscutvars[1] = 20;
2301  xmin_eleptvscutvars[1] = 0.;
2302  xmax_eleptvscutvars[1] = 2.;
2303  }else if(ih==12 || ih==13 || ih==14){
2304  //12: DCA Bachto prim, 13: DCA V0pr to prim 14: DCA V0pi to prim
2305  bins_eleptvscutvars[1] = 20;
2306  xmin_eleptvscutvars[1] = 0.;
2307  xmax_eleptvscutvars[1] = 0.5;
2308  }else if(ih==15 || ih==16){
2309  //16: CosPAXi, 15: CosPAv0
2310  bins_eleptvscutvars[1] = 20;
2311  xmin_eleptvscutvars[1] = 0.95;
2312  xmax_eleptvscutvars[1] = 1.0;
2313  }else if(ih==17 || ih==18 || ih==19){
2314  //17: nSigma(TPC, bach) 18: nSigma(TPC, v0pr), 19: nSigma(TPC,v0pi)
2315  bins_eleptvscutvars[1] = 20;
2316  xmin_eleptvscutvars[1] = -5.;
2317  xmax_eleptvscutvars[1] = 5.;
2318  }else if(ih==20 || ih==21){
2319  //20: V0 eta 21: Xi eta
2320  bins_eleptvscutvars[1] = 30;
2321  xmin_eleptvscutvars[1] = -1.5;
2322  xmax_eleptvscutvars[1] = 1.5;
2323  }else if(ih==22){
2324  //20: Opening angle
2325  bins_eleptvscutvars[1] = 20;
2326  xmin_eleptvscutvars[1] = 0.;
2327  xmax_eleptvscutvars[1] = 3.141592/2;
2328  }
2329 
2330  fHistoElePtvsCutVarsRS[ih] = new THnSparseF(Form("fHistoElePtvsCutVarsRS[%d]",ih),"",3,bins_eleptvscutvars,xmin_eleptvscutvars,xmax_eleptvscutvars);
2332  fHistoElePtvsCutVarsWS[ih] = new THnSparseF(Form("fHistoElePtvsCutVarsWS[%d]",ih),"",3,bins_eleptvscutvars,xmin_eleptvscutvars,xmax_eleptvscutvars);
2334  fHistoElePtvsCutVarsMCS[ih] = new THnSparseF(Form("fHistoElePtvsCutVarsMCS[%d]",ih),"",3,bins_eleptvscutvars,xmin_eleptvscutvars,xmax_eleptvscutvars);
2336  }
2337 
2338  return;
2339 }
2340 
2341 //________________________________________________________________________
2342 AliAODRecoCascadeHF* AliAnalysisTaskSEXic2eleXifromAODtracks::MakeCascadeHF(AliAODcascade *casc, AliAODTrack *part, AliAODEvent * aod, AliAODVertex *secVert, Bool_t mixing)
2343 {
2344  //
2345  // Create AliAODRecoCascadeHF object from the argument
2346  //
2347 
2348  if(!casc) return 0x0;
2349  if(!part) return 0x0;
2350  if(!aod) return 0x0;
2351 
2352  //------------------------------------------------
2353  // PrimaryVertex
2354  //------------------------------------------------
2355  AliAODVertex *primVertexAOD;
2356  Bool_t unsetvtx = kFALSE;
2358  primVertexAOD = CallPrimaryVertex(casc,part,aod);
2359  if(!primVertexAOD){
2360  primVertexAOD = fVtx1;
2361  }else{
2362  unsetvtx = kTRUE;
2363  }
2364  }else{
2365  primVertexAOD = fVtx1;
2366  }
2367  if(!primVertexAOD) return 0x0;
2368  Double_t posprim[3]; primVertexAOD->GetXYZ(posprim);
2369 
2370  //------------------------------------------------
2371  // DCA between tracks
2372  //------------------------------------------------
2373  AliESDtrack *esdtrack = new AliESDtrack((AliVTrack*)part);
2374 
2375  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
2376  xyz[0]=casc->DecayVertexXiX();
2377  xyz[1]=casc->DecayVertexXiY();
2378  xyz[2]=casc->DecayVertexXiZ();
2379  pxpypz[0]=casc->MomXiX();
2380  pxpypz[1]=casc->MomXiY();
2381  pxpypz[2]=casc->MomXiZ();
2382  casc->GetCovarianceXYZPxPyPz(cv);
2383  sign=casc->ChargeXi();
2384  AliExternalTrackParam *trackCasc = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
2385 
2386  Double_t xdummy, ydummy;
2387  Double_t dca = esdtrack->GetDCA(trackCasc,fBzkG,xdummy,ydummy);
2388 
2389 
2390  //------------------------------------------------
2391  // Propagate all tracks to the secondary vertex and calculate momentum there
2392  //------------------------------------------------
2393 
2394  Double_t d0z0bach[2],covd0z0bach[3];
2395  if(sqrt(pow(secVert->GetX(),2)+pow(secVert->GetY(),2))<1.){
2396  part->PropagateToDCA(secVert,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
2397  trackCasc->PropagateToDCA(secVert,fBzkG,kVeryBig);
2398  }else{
2399  part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
2400  trackCasc->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig);
2401  }
2402  Double_t momcasc_new[3]={-9999,-9999,-9999.};
2403  trackCasc->GetPxPyPz(momcasc_new);
2404 
2405  Double_t px[2],py[2],pz[2];
2406  px[0] = part->Px(); py[0] = part->Py(); pz[0] = part->Pz();
2407  px[1] = momcasc_new[0]; py[1] = momcasc_new[1]; pz[1] = momcasc_new[2];
2408 
2409  //------------------------------------------------
2410  // d0
2411  //------------------------------------------------
2412  Double_t d0[3],d0err[3];
2413 
2414  part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
2415  d0[0]= d0z0bach[0];
2416  d0err[0] = TMath::Sqrt(covd0z0bach[0]);
2417 
2418  Double_t d0z0casc[2],covd0z0casc[3];
2419  trackCasc->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0casc,covd0z0casc);
2420  d0[1]= d0z0casc[0];
2421  d0err[1] = TMath::Sqrt(covd0z0casc[0]);
2422 
2423  //------------------------------------------------
2424  // Create AliAODRecoCascadeHF
2425  //------------------------------------------------
2426  Short_t charge = part->Charge();
2427  AliAODRecoCascadeHF *theCascade = new AliAODRecoCascadeHF(secVert,charge,px,py,pz,d0,d0err,dca);
2428  if(!theCascade)
2429  {
2430  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
2431  if(esdtrack) delete esdtrack;
2432  if(trackCasc) delete trackCasc;
2433  return 0x0;
2434  }
2435  theCascade->SetOwnPrimaryVtx(primVertexAOD);
2436  UShort_t id[2]={(UShort_t)part->GetID(),(UShort_t)trackCasc->GetID()};
2437  theCascade->SetProngIDs(2,id);
2438 
2439  if(!mixing){
2440  theCascade->GetSecondaryVtx()->AddDaughter(part);
2441  theCascade->GetSecondaryVtx()->AddDaughter(casc);
2442  }
2443 
2444  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
2445  if(esdtrack) delete esdtrack;
2446  if(trackCasc) delete trackCasc;
2447 
2448  return theCascade;
2449 }
2450 
2451 //________________________________________________________________________
2452 AliAODVertex* AliAnalysisTaskSEXic2eleXifromAODtracks::CallPrimaryVertex(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent* aod)
2453 {
2454  //
2455  // Make an array of tracks which should not be used in primary vertex calculation and
2456  // Call PrimaryVertex function
2457  //
2458 
2459  TObjArray *TrackArray = new TObjArray(3);
2460 
2461  AliESDtrack *cptrk1 = new AliESDtrack((AliVTrack*)trk);
2462  TrackArray->AddAt(cptrk1,0);
2463 
2464  AliESDtrack *cascptrack = new AliESDtrack((AliVTrack*)casc->GetDaughter(0));
2465  TrackArray->AddAt(cascptrack,1);
2466  AliESDtrack *cascntrack = new AliESDtrack((AliVTrack*)casc->GetDaughter(1));
2467  TrackArray->AddAt(cascntrack,2);
2468  AliESDtrack *cascbtrack = new AliESDtrack((AliVTrack*)casc->GetDecayVertexXi()->GetDaughter(0));
2469  TrackArray->AddAt(cascbtrack,3);
2470 
2471  AliAODVertex *newvert = PrimaryVertex(TrackArray,aod);
2472 
2473  for(Int_t i=0;i<4;i++)
2474  {
2475  AliESDtrack *tesd = (AliESDtrack*)TrackArray->UncheckedAt(i);
2476  delete tesd;
2477  }
2478  TrackArray->Clear();
2479  delete TrackArray;
2480 
2481  return newvert;
2482 }
2483 
2484 //________________________________________________________________________
2485 AliAODVertex* AliAnalysisTaskSEXic2eleXifromAODtracks::PrimaryVertex(const TObjArray *trkArray,
2486  AliVEvent *event)
2487 {
2488  //
2489  //Used only for pp
2490  //copied from AliAnalysisVertexingHF (except for the following 3 lines)
2491  //
2492 
2493  Bool_t fRecoPrimVtxSkippingTrks = kTRUE;
2494  Bool_t fRmTrksFromPrimVtx = kFALSE;
2495 
2496  AliESDVertex *vertexESD = 0;
2497  AliAODVertex *vertexAOD = 0;
2498 
2499  //vertexESD = new AliESDVertex(*fV1);
2500 
2501 
2502  if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
2503  // primary vertex from the input event
2504 
2505  vertexESD = new AliESDVertex(*fV1);
2506 
2507  } else {
2508  // primary vertex specific to this candidate
2509 
2510  Int_t nTrks = trkArray->GetEntriesFast();
2511  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
2512 
2513  if(fRecoPrimVtxSkippingTrks) {
2514  // recalculating the vertex
2515 
2516  if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
2517  Float_t diamondcovxy[3];
2518  event->GetDiamondCovXY(diamondcovxy);
2519  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
2520  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
2521  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
2522  vertexer->SetVtxStart(diamond);
2523  delete diamond; diamond=NULL;
2524  if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter"))
2525  vertexer->SetOnlyFitter();
2526  }
2527  Int_t skipped[1000];
2528  Int_t nTrksToSkip=0,id;
2529  AliExternalTrackParam *t = 0;
2530  for(Int_t i=0; i<nTrks; i++) {
2531  t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
2532  id = (Int_t)t->GetID();
2533  if(id<0) continue;
2534  skipped[nTrksToSkip++] = id;
2535  }
2536  // TEMPORARY FIX
2537  // For AOD, skip also tracks without covariance matrix
2538  Double_t covtest[21];
2539  for(Int_t j=0; j<event->GetNumberOfTracks(); j++) {
2540  AliVTrack *vtrack = (AliVTrack*)event->GetTrack(j);
2541  if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
2542  id = (Int_t)vtrack->GetID();
2543  if(id<0) continue;
2544  skipped[nTrksToSkip++] = id;
2545  }
2546  }
2547  for(Int_t ijk=nTrksToSkip; ijk<1000; ijk++) skipped[ijk]=-1;
2548  //
2549  vertexer->SetSkipTracks(nTrksToSkip,skipped);
2550  vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
2551 
2552  } else if(fRmTrksFromPrimVtx && nTrks>0) {
2553  // removing the prongs tracks
2554 
2555  TObjArray rmArray(nTrks);
2556  UShort_t *rmId = new UShort_t[nTrks];
2557  AliESDtrack *esdTrack = 0;
2558  AliESDtrack *t = 0;
2559  for(Int_t i=0; i<nTrks; i++) {
2560  t = (AliESDtrack*)trkArray->UncheckedAt(i);
2561  esdTrack = new AliESDtrack(*t);
2562  rmArray.AddLast(esdTrack);
2563  if(esdTrack->GetID()>=0) {
2564  rmId[i]=(UShort_t)esdTrack->GetID();
2565  } else {
2566  rmId[i]=9999;
2567  }
2568  }
2569  Float_t diamondxy[2]={static_cast<Float_t>(event->GetDiamondX()),static_cast<Float_t>(event->GetDiamondY())};
2570  vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
2571  delete [] rmId; rmId=NULL;
2572  rmArray.Delete();
2573 
2574  }
2575 
2576  delete vertexer; vertexer=NULL;
2577  if(!vertexESD) return vertexAOD;
2578  if(vertexESD->GetNContributors()<=0) {
2579  //AliDebug(2,"vertexing failed");
2580  delete vertexESD; vertexESD=NULL;
2581  return vertexAOD;
2582  }
2583 
2584 
2585  }
2586 
2587  // convert to AliAODVertex
2588  Double_t pos[3],cov[6],chi2perNDF;
2589  vertexESD->GetXYZ(pos); // position
2590  vertexESD->GetCovMatrix(cov); //covariance matrix
2591  chi2perNDF = vertexESD->GetChi2toNDF();
2592  delete vertexESD; vertexESD=NULL;
2593 
2594  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
2595 
2596  return vertexAOD;
2597 }
2598 
2599 //________________________________________________________________________
2600 AliAODVertex* AliAnalysisTaskSEXic2eleXifromAODtracks::ReconstructSecondaryVertex(AliAODcascade *casc, AliAODTrack *part, AliAODEvent * aod)
2601 {
2602  //
2603  // Reconstruct secondary vertex from trkArray (Copied from AliAnalysisVertexingHF)
2604  //
2605 
2606  AliAODVertex *primVertexAOD;
2607  Bool_t unsetvtx = kFALSE;
2609  primVertexAOD = CallPrimaryVertex(casc,part,aod);
2610  if(!primVertexAOD){
2611  primVertexAOD = fVtx1;
2612  }else{
2613  unsetvtx = kTRUE;
2614  }
2615  }else{
2616  primVertexAOD = fVtx1;
2617  }
2618  if(!primVertexAOD) return 0x0;
2619 
2620  AliESDVertex * vertexESD = new AliESDVertex(*fV1);
2621 
2622  Double_t pos[3],cov[6],chi2perNDF;
2623  vertexESD->GetXYZ(pos); // position
2624  vertexESD->GetCovMatrix(cov); //covariance matrix
2625  chi2perNDF = vertexESD->GetChi2toNDF();
2626  delete vertexESD; vertexESD=NULL;
2627 
2628  AliAODVertex *secVert = new AliAODVertex(pos,cov,chi2perNDF);
2629 
2630  return secVert;
2631 }
2632 //________________________________________________________________________
2633 Int_t AliAnalysisTaskSEXic2eleXifromAODtracks::MatchToMC(AliAODRecoCascadeHF *exobj, TClonesArray *mcArray, Int_t *pdgarray_ele, Int_t *pdgarray_casc, Int_t *labelarray_ele, Int_t *labelarray_casc, Int_t &ngen_ele, Int_t &ngen_casc)
2634 {
2635  //
2636  // Match to MC
2637  //
2638  for(Int_t i=0;i<100;i++){
2639  pdgarray_ele[i] = -9999;
2640  labelarray_ele[i] = -9999;
2641  pdgarray_casc[i] = -9999;
2642  labelarray_casc[i] = -9999;
2643  }
2644  ngen_ele = 0;
2645  ngen_casc = 0;
2646 
2647  AliVTrack *trk = dynamic_cast<AliVTrack*>(exobj->GetBachelor());
2648  if(!trk) return -1;
2649  Int_t labEle = trk->GetLabel();
2650  if(labEle<0) return -1;
2651  AliAODMCParticle *mcetrk = (AliAODMCParticle*)mcArray->At(labEle);
2652  if(!mcetrk) return -1;
2653  labelarray_ele[0] = labEle;
2654  pdgarray_ele[0] = mcetrk->GetPdgCode();
2655  ngen_ele ++;
2656 
2657  AliAODMCParticle *mcprimele=0;
2658  mcprimele = mcetrk;
2659  while(mcprimele->GetMother()>=0) {
2660  Int_t labprim_ele=mcprimele->GetMother();
2661  AliAODMCParticle *tmcprimele = (AliAODMCParticle*)mcArray->At(labprim_ele);
2662  if(!tmcprimele) {
2663  break;
2664  }
2665 
2666  mcprimele = tmcprimele;
2667  pdgarray_ele[ngen_ele] = mcprimele->GetPdgCode();
2668  labelarray_ele[ngen_ele] = labprim_ele;
2669  ngen_ele ++;
2670  if(ngen_ele==100) break;
2671  }
2672 
2673  AliAODcascade *theCascade = dynamic_cast<AliAODcascade*>(exobj->GetCascade());
2674  if(!theCascade) return -1;
2675 
2676  Int_t pdgDgcasc[2]={211,3122};
2677  Int_t pdgDgv0[2]={2212,211};
2678  Int_t labcasc = MatchToMCCascade(theCascade,3312,pdgDgcasc,pdgDgv0,mcArray); // the cascade
2679  if(labcasc<0) return -1;
2680 
2681  AliAODMCParticle *mccasc = (AliAODMCParticle*)mcArray->At(labcasc);
2682  if(!mccasc) return -1;
2683  labelarray_casc[0] = labcasc;
2684  pdgarray_casc[0] = mccasc->GetPdgCode();
2685  ngen_casc ++;
2686 
2687  AliAODMCParticle *mcprimcasc=0;
2688  mcprimcasc = mccasc;
2689  while(mcprimcasc->GetMother()>=0) {
2690  Int_t labprim_casc=mcprimcasc->GetMother();
2691  AliAODMCParticle *tmcprimcasc = (AliAODMCParticle*)mcArray->At(labprim_casc);
2692  if(!tmcprimcasc) {
2693  break;
2694  }
2695 
2696  mcprimcasc = tmcprimcasc;
2697  pdgarray_casc[ngen_casc] = mcprimcasc->GetPdgCode();
2698  labelarray_casc[ngen_casc] = labprim_casc;
2699  ngen_casc ++;
2700  if(ngen_casc==100) break;
2701  }
2702 
2703  Bool_t same_flag = kFALSE;
2704  Int_t matchedlabel=-9999;
2705  for(Int_t iemc=0;iemc<ngen_ele;iemc++){
2706  for(Int_t ivmc=0;ivmc<ngen_casc;ivmc++){
2707  if(labelarray_ele[iemc]==labelarray_casc[ivmc]){
2708  same_flag = kTRUE;
2709  matchedlabel = labelarray_ele[iemc];
2710  break;
2711  }
2712  }
2713  if(same_flag) break;
2714  }
2715 
2716  return matchedlabel;
2717 
2718 }
2719 //________________________________________________________________________
2720 Int_t AliAnalysisTaskSEXic2eleXifromAODtracks::MatchToMCCascade(AliAODcascade *theCascade, Int_t pdgabscasc, Int_t *pdgDgcasc, Int_t *pdgDgv0, TClonesArray *mcArray) const // the cascade
2721 {
2722  //
2723  // Matching to MC of cascade
2724  //
2725 
2726  AliAODTrack *cptrack = (AliAODTrack*) theCascade->GetDaughter(0);
2727  if(!cptrack) return -1;
2728  Int_t label_p = cptrack->GetLabel();
2729  if(label_p<0) return -1;
2730  AliAODTrack *cntrack = (AliAODTrack*) theCascade->GetDaughter(1);
2731  if(!cntrack) return -1;
2732  Int_t label_n = cntrack->GetLabel();
2733  if(label_n<0) return -1;
2734  Int_t labv0 = theCascade->MatchToMC(pdgDgcasc[1],mcArray,2,pdgDgv0);
2735  if(labv0<0) return -1;
2736  AliAODMCParticle *mcpartv0= (AliAODMCParticle*) mcArray->At(labv0);
2737 
2738  AliAODTrack *cbtrack = (AliAODTrack*) theCascade->GetDecayVertexXi()->GetDaughter(0);
2739  if(!cbtrack) return -1;
2740 
2741  Int_t label_b = cbtrack->GetLabel();
2742  if(label_b<0) return -1;
2743 
2744  AliAODMCParticle *mcpartb= (AliAODMCParticle*) mcArray->At(label_b);
2745  Int_t pdgb = TMath::Abs(mcpartb->GetPdgCode());
2746  if(pdgb!=pdgDgcasc[0]) return -1;
2747 
2748  AliAODMCParticle *mcmotherv0=mcpartv0;
2749  Bool_t isFromXiv0 = kFALSE;
2750  Int_t labxiv0 = mcmotherv0->GetMother();
2751  if(labxiv0<0) return -1;
2752  mcmotherv0 = (AliAODMCParticle*) mcArray->At(labxiv0);
2753  if(mcmotherv0){
2754  Int_t pdg = TMath::Abs(mcmotherv0 ->GetPdgCode());
2755  if(pdg==pdgabscasc){
2756  isFromXiv0 = kTRUE;
2757  }
2758  }
2759  if(!isFromXiv0) return -1;
2760 
2761  AliAODMCParticle *mcmotherb=mcpartb;
2762  Bool_t isFromXib = kFALSE;
2763  Int_t labxib = mcmotherb->GetMother();
2764  if(labxib<0) return -1;
2765  mcmotherb = (AliAODMCParticle*) mcArray->At(labxib);
2766  if(mcmotherb){
2767  Int_t pdg = TMath::Abs(mcmotherb ->GetPdgCode());
2768  if(pdg==pdgabscasc){
2769  isFromXib = kTRUE;
2770  }
2771  }
2772  if(!isFromXib) return -1;
2773 
2774  if(labxiv0!=labxib) return -1;//Bachelor and V0 should come from the same Xi
2775 
2776  return labxib;
2777 }
2778 //________________________________________________________________________
2779 void AliAnalysisTaskSEXic2eleXifromAODtracks::SelectTrack( const AliVEvent *event, Int_t trkEntries, Int_t &nSeleTrks,Bool_t *seleFlags, TClonesArray *mcArray)
2780 {
2781  //
2782  // Select good tracks using fAnalCuts (AliRDHFCuts object) and return the array of their ids
2783  //
2784 
2785  //const Int_t entries = event->GetNumberOfTracks();
2786  if(trkEntries==0) return;
2787 
2788  nSeleTrks=0;
2789  for(Int_t i=0; i<trkEntries; i++) {
2790  seleFlags[i] = kFALSE;
2791 
2792  AliVTrack *track;
2793  track = (AliVTrack*)event->GetTrack(i);
2794 
2795  if(track->GetID()<0) continue;
2796  Double_t covtest[21];
2797  if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
2798 
2799  AliAODTrack *aodt = (AliAODTrack*)track;
2800  Double_t nsigma_tpcele = -9999;
2801  Double_t nsigma_tofele = -9999;
2802  if(fAnalCuts->GetIsUsePID()){
2803  nsigma_tpcele = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(aodt,AliPID::kElectron);
2804  nsigma_tofele = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(aodt,AliPID::kElectron);
2805  }
2806 
2807  if(!fAnalCuts) continue;
2808  if(fAnalCuts->SingleTrkCutsNoPID(aodt,fVtx1)){
2809  fHistoElectronTPCPID->Fill(aodt->Pt(),nsigma_tpcele);
2810  fHistoElectronTOFPID->Fill(aodt->Pt(),nsigma_tofele);
2811  if(fabs(nsigma_tofele)<3.){
2812  fHistoElectronTPCPIDSelTOF->Fill(aodt->Pt(),nsigma_tpcele);
2813  Double_t eleeta = aodt->Eta();
2814  if(fabs(eleeta)<0.6)
2815  fHistoElectronTPCPIDSelTOFSmallEta->Fill(aodt->Pt(),nsigma_tpcele);
2816  if(fabs(eleeta)>0.6 && fabs(eleeta)<0.8)
2817  fHistoElectronTPCPIDSelTOFLargeEta->Fill(aodt->Pt(),nsigma_tpcele);
2818  if(eleeta>-0.8 && eleeta<-0.6){
2819  fHistoElectronTPCPIDSelTOFEtaDep[0]->Fill(aodt->Pt(),nsigma_tpcele);
2820  }else if(eleeta>-0.6&&eleeta<-0.4){
2821  fHistoElectronTPCPIDSelTOFEtaDep[1]->Fill(aodt->Pt(),nsigma_tpcele);
2822  }else if(eleeta>-0.4&&eleeta<-0.2){
2823  fHistoElectronTPCPIDSelTOFEtaDep[2]->Fill(aodt->Pt(),nsigma_tpcele);
2824  }else if(eleeta>-0.2&&eleeta<0.0){
2825  fHistoElectronTPCPIDSelTOFEtaDep[3]->Fill(aodt->Pt(),nsigma_tpcele);
2826  }else if(eleeta>0.0&&eleeta<0.2){
2827  fHistoElectronTPCPIDSelTOFEtaDep[4]->Fill(aodt->Pt(),nsigma_tpcele);
2828  }else if(eleeta>0.2&&eleeta<0.4){
2829  fHistoElectronTPCPIDSelTOFEtaDep[5]->Fill(aodt->Pt(),nsigma_tpcele);
2830  }else if(eleeta>0.4&&eleeta<0.6){
2831  fHistoElectronTPCPIDSelTOFEtaDep[6]->Fill(aodt->Pt(),nsigma_tpcele);
2832  }else if(eleeta>0.6&&eleeta<0.8){
2833  fHistoElectronTPCPIDSelTOFEtaDep[7]->Fill(aodt->Pt(),nsigma_tpcele);
2834  }
2835  }
2836  }
2837  if(fAnalCuts->SingleTrkCuts(aodt,fVtx1)){
2838  seleFlags[i]=kTRUE;
2839  nSeleTrks++;
2840  fHistoElectronTPCSelPID->Fill(aodt->Pt(),nsigma_tpcele);
2841  fHistoElectronTOFSelPID->Fill(aodt->Pt(),nsigma_tofele);
2842  FillElectronROOTObjects(aodt,mcArray);
2843  if(fDoEventMixing){
2844  fElectronTracks->AddLast(new AliAODTrack(*aodt));
2845  }
2846  }
2847  } // end loop on tracks
2848 }
2849 //________________________________________________________________________
2850 void AliAnalysisTaskSEXic2eleXifromAODtracks::SelectCascade( const AliVEvent *event,Int_t nCascs,Int_t &nSeleCasc, Bool_t *seleCascFlags, TClonesArray *mcArray)
2851 {
2852  //
2853  // Select good Casc using fAnalCuts (AliRDHFCuts object) and return the array of their ids
2854  //
2855 
2856  Double_t primVtx[3];
2857  fVtx1->GetXYZ(primVtx);
2858 
2859  nSeleCasc = 0;
2860  for(Int_t icasc=0;icasc<nCascs;icasc++)
2861  {
2862  seleCascFlags[icasc] = kFALSE;
2863  AliAODcascade *casc = ((AliAODEvent*)event)->GetCascade(icasc);
2864 
2865  if(!fAnalCuts) continue;
2866  if(fAnalCuts->SingleCascadeCuts(casc,primVtx)){
2867  seleCascFlags[icasc] = kTRUE;
2868  nSeleCasc++;
2869 
2870 // AliAODTrack *cptrack = (AliAODTrack*)(casc->GetDaughter(0));
2871 // AliAODTrack *cntrack = (AliAODTrack*)(casc->GetDaughter(1));
2872 // AliAODTrack *cbtrack = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0));
2873 // cout<<"Xi: "<<casc->MomXiX()<<" "<<casc->MomXiY()<<" "<<casc->MomXiZ()<<endl;
2874 // cout<<"V0: "<<casc->Px()<<" "<<casc->Py()<<" "<<casc->Pz()<<endl;
2875 // cout<<"from casc"<<endl;
2876 // cout<<casc->DecayVertexV0X()<<" "<<casc->DecayVertexV0Y()<<" "<<casc->DecayVertexV0Z()<<" "<<casc->MomPosX()<<" "<<casc->MomPosY()<<" "<<casc->MomPosZ()<<endl;
2877 // cout<<casc->DecayVertexV0X()<<" "<<casc->DecayVertexV0Y()<<" "<<casc->DecayVertexV0Z()<<" "<<casc->MomNegX()<<" "<<casc->MomNegY()<<" "<<casc->MomNegZ()<<endl;
2878 // cout<<casc->DecayVertexXiX()<<" "<<casc->DecayVertexXiY()<<" "<<casc->DecayVertexXiZ()<<" "<<casc->MomBachX()<<" "<<casc->MomBachY()<<" "<<casc->MomBachZ()<<endl;
2879 // cout<<"from track"<<endl;
2880 // cout<<cptrack->Xv()<<" "<<cptrack->Yv()<<" "<<cptrack->Zv()<<" "<<cptrack->Px()<<" "<<cptrack->Py()<<" "<<cptrack->Pz()<<endl;
2881 // cout<<cntrack->Xv()<<" "<<cntrack->Yv()<<" "<<cntrack->Zv()<<" "<<cntrack->Px()<<" "<<cntrack->Py()<<" "<<cntrack->Pz()<<endl;
2882 // cout<<cbtrack->Xv()<<" "<<cbtrack->Yv()<<" "<<cbtrack->Zv()<<" "<<cbtrack->Px()<<" "<<cbtrack->Py()<<" "<<cbtrack->Pz()<<endl;
2883 //
2884 // cout<<"pos charge: "<<cptrack->Charge()<<endl;
2885 // cout<<"exact"<<endl;
2886 // Double_t xyz_cptrack[3];
2887 // cptrack->GetXYZAt(3.9,fBzkG,xyz_cptrack);
2888 // cout<<xyz_cptrack[0]<<" "<<xyz_cptrack[1]<<" "<<xyz_cptrack[2]<<endl;
2889 // cout<<"hand"<<endl;
2890 // cout<<"i am here1"<<endl;
2891 // Double_t v0vertr = 0.01*sqrt(casc->DecayVertexV0X()*casc->DecayVertexV0X()+casc->DecayVertexV0Y()*casc->DecayVertexV0Y());
2892 // cout<<"i am here2"<<endl;
2893 // Double_t v0pospt = sqrt(casc->MomPosX()*casc->MomPosX()+casc->MomPosY()*casc->MomPosY());
2894 // cout<<"i am here3"<<endl;
2895 // Double_t phi_atR = atan2(casc->DecayVertexV0Y(),casc->DecayVertexV0X())-asin((1.*0.3*0.5*v0vertr)/(2*v0pospt))+asin((1.*0.3*0.5*0.039)/(2*v0pospt));
2896 // cout<<"i am here4"<<endl;
2897 // //Double_t phi_atR = phi-asin((charge*0.3*0.5*R)/(2*pt));
2898 // if(phi_atR<-M_PI) phi_atR += 2 * M_PI;
2899 // if(phi_atR>M_PI) phi_atR -= 2 * M_PI;
2900 // cout<<3.9*cos(phi_atR)<<" "<<3.9*sin(phi_atR)<<endl;
2901 // cout<<endl;
2902 
2903  FillCascROOTObjects(casc,mcArray);
2904  }
2905  }
2906 }
2907 //_________________________________________________________________
2908 Int_t AliAnalysisTaskSEXic2eleXifromAODtracks::GetPoolIndex(Double_t zvert, Double_t mult){
2909  //
2910  // check in which of the pools the current event falls
2911  //
2912 
2913  Int_t theBinZ=TMath::BinarySearch(fNzVtxBins,fZvtxBins,zvert);
2914  if(theBinZ<0 || theBinZ>=fNzVtxBins) return -1;
2915  Int_t theBinM=TMath::BinarySearch(fNCentBins,fCentBins,mult);
2916  if(theBinM<0 || theBinM>=fNCentBins) return -1;
2917  return fNCentBins*theBinZ+theBinM;
2918 }
2919 //_________________________________________________________________
2921  //
2922  // delete the contets of the pool
2923  //
2924  if(poolIndex<0 || poolIndex>=fNOfPools) return;
2925  delete fEventBuffer[poolIndex];
2926  fEventBuffer[poolIndex]=new TTree(Form("EventBuffer_%d",poolIndex), "Temporary buffer for event mixing");
2927 
2928  fEventBuffer[poolIndex]->Branch("zVertex", &fVtxZ);
2929  fEventBuffer[poolIndex]->Branch("centrality", &fCentrality);
2930  fEventBuffer[poolIndex]->Branch("eventInfo", "TObjString",&fEventInfo);
2931  fEventBuffer[poolIndex]->Branch("earray", "TObjArray", &fElectronTracks);
2932 
2933  return;
2934 }
2935 //_________________________________________________________________
2936 void AliAnalysisTaskSEXic2eleXifromAODtracks::DoEventMixingWithPools(Int_t poolIndex,AliAODEvent *aodEvent, Bool_t *seleFlags)
2937 {
2938  //
2939  // perform mixed event analysis
2940  //
2941 
2942  if(poolIndex<0 || poolIndex>fNzVtxBins*fNCentBins) return;
2943  if(fEventBuffer[poolIndex]->GetEntries()<fNumberOfEventsForMixing) return;
2944 
2945  Int_t nEvents=fEventBuffer[poolIndex]->GetEntries();
2946 
2947  TObjArray* earray=0x0;
2948  Float_t zVertex,cent;
2949  TObjString* eventInfo=0x0;
2950  fEventBuffer[poolIndex]->SetBranchAddress("earray", &earray);
2951  fEventBuffer[poolIndex]->SetBranchAddress("eventInfo",&eventInfo);
2952  fEventBuffer[poolIndex]->SetBranchAddress("zVertex", &zVertex);
2953  fEventBuffer[poolIndex]->SetBranchAddress("centrality", &cent);
2954  for (Int_t i=0; i<aodEvent->GetNumberOfCascades(); i++)
2955  {
2956  if(!seleFlags[i]) continue;
2957  AliAODcascade* casc = aodEvent->GetCascade(i);
2958  if(!casc)continue;
2959 
2960  for(Int_t iEv=0; iEv<fNumberOfEventsForMixing; iEv++){
2961  fEventBuffer[poolIndex]->GetEvent(iEv + nEvents - fNumberOfEventsForMixing);
2962  TObjArray* earray1=(TObjArray*)earray->Clone();
2963  //Float_t zVertex1=zVertex;
2964  //Float_t mult1=cent;
2965  Int_t nElectrons=earray1->GetEntries();
2966  //Int_t evId1,esdId1,ne1;
2967  //sscanf((eventInfo->String()).Data(),"Ev%d_esd%d_K%d",&evId1,&esdId1,&ne1);
2968 // if(ne1!=nElectrons){
2969 // printf("AliAnalysisTaskSEXic2eleXifromAODtracks::DoMixingWithPools ERROR: read event does not match to the stored one\n");
2970 // delete earray1;
2971 // continue;
2972 // }
2973  for(Int_t iTr1=0; iTr1<nElectrons; iTr1++){
2974  AliAODTrack* trk1=(AliAODTrack*)earray1->At(iTr1);
2975  if(!trk1) continue;
2976 
2977  AliAODVertex *secVert = ReconstructSecondaryVertex(casc,trk1,aodEvent);//Fake, prim vertex is just used as secondary vertex. place holder for future
2978  if(!secVert) continue;
2979 
2980  AliAODRecoCascadeHF *exobj = MakeCascadeHF(casc,trk1,aodEvent,secVert,true);
2981  if(!exobj) {
2982  continue;
2983  }
2984 
2985  TClonesArray *fake = 0;
2986  FillROOTObjects(exobj,casc,trk1,fake,true);
2987 
2988  exobj->GetSecondaryVtx()->RemoveDaughters();
2989  exobj->UnsetOwnPrimaryVtx();
2990  delete exobj;exobj=NULL;
2991  delete secVert;
2992  }//track loop
2993 
2994  delete earray1;
2995  }//event loop
2996 
2997  }//v0 loop
2998 }
2999 //_________________________________________________________________
3001 {
3002  //
3003  // Analyze AliAODmcparticle
3004  //
3005 
3006  Int_t nmcpart = mcArray->GetEntriesFast();
3007  for(Int_t i=0;i<nmcpart;i++)
3008  {
3009  AliAODMCParticle *mcpart = (AliAODMCParticle*) mcArray->At(i);
3010  if(TMath::Abs(mcpart->GetPdgCode())==4132){
3011  Bool_t e_flag = kFALSE;
3012  Bool_t xi_flag = kFALSE;
3013  AliAODMCParticle *mcepart = 0;
3014  AliAODMCParticle *mccascpart = 0;
3015  for(Int_t idau=mcpart->GetFirstDaughter();idau<mcpart->GetLastDaughter()+1;idau++)
3016  {
3017  if(idau<0) break;
3018  AliAODMCParticle *mcdau = (AliAODMCParticle*) mcArray->At(idau);
3019  if(!mcdau) continue;
3020  if(TMath::Abs(mcdau->GetPdgCode())==11){
3021  e_flag = kTRUE;
3022  mcepart = mcdau;
3023  }
3024  if(TMath::Abs(mcdau->GetPdgCode())==3312){
3025  xi_flag = kTRUE;
3026  mccascpart = mcdau;
3027  }
3028  }
3029 
3030  Int_t decaytype = -9999;
3031  if(e_flag && xi_flag) decaytype = 0;
3032 
3033  FillMCROOTObjects(mcpart,mcepart,mccascpart,decaytype);
3034  }
3035  if(TMath::Abs(mcpart->GetPdgCode())==11 && mcpart->GetStatus()==1){
3036  AliESDtrackCuts *esdcuts = fAnalCuts->GetTrackCuts();
3037  Float_t etamin, etamax;
3038  esdcuts->GetEtaRange(etamin,etamax);
3039  if(fabs(mcpart->Eta())<etamax){
3040  fHistoBachPtMCGen->Fill(mcpart->Pt());
3041  }
3042  FillMCEleROOTObjects(mcpart, mcArray);
3043  }
3044  if(TMath::Abs(mcpart->GetPdgCode())==3312){
3045  Double_t etamin, etamax, rapmin, rapmax;
3046  fAnalCuts->GetProdCascEtaRange(etamin,etamax);
3047  fAnalCuts->GetProdCascRapRange(rapmin,rapmax);
3048 
3049  if((fabs(mcpart->Y())<rapmax) && (fabs(mcpart->Eta())<etamax)){
3050  fHistoXiMassvsPtMCGen->Fill(1.32171, mcpart->Pt());
3051  }
3052  FillMCCascROOTObjects(mcpart, mcArray);
3053  }
3054  }
3055  return;
3056 }
Int_t charge
Int_t pdg
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
THnSparse * fHistoElePtvsXiPtMCGen
! e-Xi spectra efficiency denominator
Bool_t IsEventRejectedDueToNotRecoVertex() const
Definition: AliRDHFCuts.h:298
Bool_t SingleCascadeCuts(AliAODcascade *casc, Double_t *vert)
TH1F * fHistoBachPtMCGen
! Bachelor pT histogram (efficiency denominator)
THnSparse * fHistoElePtvsd0RS
! e pt-d0 spectra (right-sign)
TH2F * fHistoElectronTPCPIDSelTOFEtaDep[8]
! TPC electron PID after TOF 3 sigma cut Eta dep
Bool_t fWriteMCVariableTree
flag to decide whether to write the candidate variables on a tree variables
Int_t MatchToMCCascade(AliAODcascade *theCascade, Int_t pdgabscasc, Int_t *pdgDgcasc, Int_t *pdgDgv0, TClonesArray *mcArray) const
Float_t * fCandidateCascVariables
! variables to be written to the tree
THnSparse * fHistoElePtvsXiPtRSMix
! e-Xi spectra (right-sign, mix)
Float_t * fCandidateMCVariables
! variables to be written to the tree
void SelectTrack(const AliVEvent *event, Int_t trkEntries, Int_t &nSeleTrks, Bool_t *seleFlags, TClonesArray *mcArray)
THnSparse * fHistoElePtvsCutVarsRS[23]
! e pt- cut variables (Right-sign)
void FillMCEleROOTObjects(AliAODMCParticle *mcepart, TClonesArray *mcArray)
TList * fOutputAll
! User Output slot 3 //analysis histograms
THnSparse * fHistoElePtvsd0MCS
! e pt-d0 spectra (right-sign)
THnSparse * fHistoElePtvsd0PromptMCS
! e pt-d0 spectra (right-sign)
THnSparse * fHistoElePtvsXiPtvsXicPtMCS
! e-Xi spectra efficiency numerator
TTree * fMCCascVariablesTree
! tree of the candidate variables after track selection on output slot 4
THnSparse * fHistoEleXiMassvsElePtMCGen
! e-Xi mass-ept spectra (Efficiency denominator)
THnSparse * fHistoElectronMCGen
! electron in mcArray (only from charmed baryon)
THnSparse * fHistoEleXiMassvsElePtRS
! e-Xi mass spectra (right-sign)
void FillElectronROOTObjects(AliAODTrack *trk, TClonesArray *mcArray)
THnSparse * fHistoEleXiMassRS
! e-Xi mass spectra (right-sign)
THnSparse * fHistoElePtvsEtaWSMix
! e spectra (wrong-sign, mix)
Int_t MatchToMC(AliAODRecoCascadeHF *elobj, TClonesArray *mcArray, Int_t *pdgarray_ele, Int_t *pdgarray_casc, Int_t *labelarray_ele, Int_t *labelarray_casc, Int_t &ngen_ele, Int_t &ngen_casc)
THnSparse * fHistoElePtvsXiPtWSMix
! e-Xi spectra (wrong-sign, mix)
TTree * fCascVariablesTree
! tree of the candidate variables after track selection on output slot 4
virtual void UserCreateOutputObjects()
Implementation of interface methods.
THnSparse * fHistoElePtvsd0WS
! e pt-d0 spectra (wrong-sign)
Float_t * fCandidateEleVariables
! variables to be written to the tree
TTree * fMCEleVariablesTree
! tree of the candidate variables after track selection on output slot 4
Double_t GetMaxVtxZ() const
Definition: AliRDHFCuts.h:241
void FillMCROOTObjects(AliAODMCParticle *part, AliAODMCParticle *mcepart, AliAODMCParticle *mcv0part, Int_t decaytype)
THnSparse * fHistoElePtvsEtaMCGen
! e spectra efficiency denominator
THnSparse * fHistoEleXiMassMCGen
! e-Xi mass spectra (Efficiency denominator)
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:231
THnSparse * fHistoElePtvsEtaMCS
! e spectra efficiency numerator
TTree * fMCVariablesTree
! tree of the candidate variables after track selection on output slot 4
Bool_t SingleTrkCuts(AliAODTrack *trk, AliAODVertex *primvert)
THnSparse * fHistoElePtvsXiPtMCS
! e-Xi spectra efficiency numerator
THnSparse * fHistoEleXiMassWS
! e-Xi mass spectra (wrong-sign)
THnSparse * fHistoElePtvsCutVarsWS[23]
! e pt- cut variables (Wrong-sign)
const Double_t etamin
TH1F * fHistoBachPtMCS
! Bachelor pT histogram (efficiency numerator)
void MakeAnalysis(AliAODEvent *aod, TClonesArray *mcArray)
AliAODVertex * PrimaryVertex(const TObjArray *trkArray, AliVEvent *event)
THnSparse * fHistoEleXiMassvsElePtMCS
! e-Xi mass-ept spectra (Efficiency numerator)
void FillMCCascROOTObjects(AliAODMCParticle *mccpart, TClonesArray *mcArray)
THnSparse * fHistoElePtvsCutVarsMCS[23]
! e pt- cut variables (MCS)
THnSparse * fHistoXiMCGen
! Xi in mcArray (only from charmed baryon)
THnSparse * fHistoElePtvsXiPtRS
! e-Xi spectra (right-sign)
TH2F * fHistoElePtMCS
! e spectra (Efficiency numerator)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
TH2F * fHistoElectronTOFSelPID
! TOF electron PID after selection
Float_t * fCandidateMCCascVariables
! variables to be written to the tree
AliAODTrack * GetBachelor() const
Float_t * fCandidateMCEleVariables
! variables to be written to the tree
THnSparse * fHistoEleXiMassMCS
! e-Xi mass spectra (Efficiency numerator)
TTree * fEleVariablesTree
flag to decide whether to write the candidate variables on a tree variables
AliESDtrackCuts * GetTrackCuts() const
Definition: AliRDHFCuts.h:245
TObjArray * fElectronTracks
unique event id for mixed event check
TH1F * fCEvents
! Histogram to check selected events
void SetProngIDs(Int_t nIDs, UShort_t *id)
TH2F * fHistoElectronTPCPIDSelTOFSmallEta
! TPC electron PID after TOF 3 sigma cut (|eta|<0.6)
THnSparse * fHistoElePtvsd0WSMix
! e pt-d0 spectra (wrong-sign, mix)
TH2F * fHistoElectronTPCPIDSelTOF
! TPC electron PID after TOF 3 sigma cut
AliPIDResponse * GetPidResponse() const
Definition: AliAODPidHF.h:160
AliAODRecoCascadeHF * MakeCascadeHF(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent *aod, AliAODVertex *vert, Bool_t mixing)
AliNormalizationCounter * fCounter
! Counter for normalization
Int_t fNzVtxBins
maximum number of events to be used in event mixing
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)
Bool_t IsEventRejectedDuePhysicsSelection() const
Definition: AliRDHFCuts.h:319
void SetOwnPrimaryVtx(const AliAODVertex *vtx)
AliAODcascade * GetCascade() const
TH2F * fHistoElePtMCGen
! e spectra (Efficiency denominator)
THnSparse * fHistoElePtvsd0RSMix
! e pt-d0 spectra (right-sign, mix)
void FillCascROOTObjects(AliAODcascade *casc, TClonesArray *mcArray)
Bool_t IsEventSelected(AliVEvent *event)
THnSparse * fHistoElePtvsXiPtWS
! e-Xi spectra (wrong-sign)
AliAODVertex * ReconstructSecondaryVertex(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent *aod)
Float_t nEvents[nProd]
AliAODVertex * CallPrimaryVertex(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent *evt)
TH2F * fHistoElectronTPCPIDSelTOFLargeEta
! TPC electron PID after TOF 3 sigma cut (0.8>|eta|>0.6)
THnSparse * fHistoEleXiMassvsElePtWSMix
! e-Xi mass-ept spectra (wrong-sign)
Bool_t fIsMB
Reconstruct primary vertex excluding candidate tracks.
THnSparse * fHistoElePtvsEtaRSMix
! e spectra (right-sign, mix)
THnSparse * fHistoEleXiMassvsElePtRSMix
! e-Xi mass-ept spectra (right-sign)
const Double_t etamax
THnSparse * fHistoElePtvsd0BFeeddownMCS
! e pt-d0 spectra (right-sign)
Bool_t SingleTrkCutsNoPID(AliAODTrack *trk, AliAODVertex *primvert)
Bool_t GetIsUsePID() const
Definition: AliRDHFCuts.h:253
void SelectCascade(const AliVEvent *event, Int_t nCasc, Int_t &nSeleCasc, Bool_t *seleCascFlags, TClonesArray *mcArray)
Bool_t IsEventRejectedDueToTrigger() const
Definition: AliRDHFCuts.h:295
void StoreEvent(AliVEvent *, AliRDHFCuts *, Bool_t mc=kFALSE, Int_t multiplicity=-9999)
void DoEventMixingWithPools(Int_t index, AliAODEvent *aodEvent, Bool_t *seleFlags)
TH2F * fHistoElectronTPCSelPID
! TPC electron PID after selection
THnSparse * fHistoEleXiMassRSMix
! e-Xi mass spectra (right-sign)
THnSparse * fHistoEleXiMassvsElePtWS
! e-Xi mass spectra (wrong-sign)
THnSparse * fHistoEleXiMassWSMix
! e-Xi mass spectra (wrong-sign)
THnSparse * fHistoElePtvsXiPtMCXicGen
! e-Xi spectra efficiency denominator
void FillROOTObjects(AliAODRecoCascadeHF *elobj, AliAODcascade *casc, AliAODTrack *trk, TClonesArray *mcArray, Bool_t mixing)
THnSparse * fHistoElePtvsXiPtvsXicPtMCGen
! e-Xi spectra efficiency numerator
TTree * fVariablesTree
flag to decide whether to write the candidate variables on a tree variables