3088c0bf9fb7bd55d2b3903dfd00e471f5da56cb
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Hypernuclei / AliAnalysisTaskReadNuclexAOD.cxx
1 /**************************************************************************
2  * Contributors are not mentioned at all.                                 *
3  *                                                                        *
4  * Permission to use, copy, modify and distribute this software and its   *
5  * documentation strictly for non-commercial purposes is hereby granted   *
6  * without fee, provided that the above copyright notice appears in all   *
7  * copies and that both the copyright notice and this permission notice   *
8  * appear in the supporting documentation. The authors make no claims     *
9  * about the suitability of this software for any purpose. It is          *
10  * provided "as is" without express or implied warranty.                  *
11  **************************************************************************/
12
13 //
14 //-----------------------------------------------------------------
15 //                 AliAnalysisTaskNUclexAOD class AOD
16 //-----------------------------------------------------------------
17
18
19 class TTree;
20 class TParticle;
21 class TVector3;
22
23 #include "AliAnalysisManager.h"
24 #include <AliMCEventHandler.h>
25 #include <AliMCEvent.h>
26 #include <AliStack.h>
27
28 class AliESDVertex;
29 class AliAODVertex;
30 class AliESDv0;
31 class AliAODv0; 
32 class AliCascadeVertexer;
33
34 #include <iostream>
35 #include "AliAnalysisTaskSE.h"
36 #include "TList.h"
37 #include "TH1.h"
38 #include "TH2.h"
39 #include "TH3.h"
40 #include "TNtuple.h"
41 #include "TGraph.h"
42 #include "TCutG.h"
43 #include "TF1.h"
44 #include "TCanvas.h"
45 #include "TMath.h"
46 #include "TChain.h"
47 #include "Riostream.h"
48 #include "AliLog.h"
49 #include "AliCascadeVertexer.h"
50 #include "AliESDEvent.h"
51 #include "AliESDtrack.h"
52 #include "AliExternalTrackParam.h"
53 #include "AliAODEvent.h"
54 #include "AliInputEventHandler.h"
55 #include "AliESDcascade.h"
56 #include "AliAODcascade.h"
57 #include "AliAnalysisTaskReadNuclexAOD.h"
58 #include "AliESDtrackCuts.h"
59 #include "AliCentrality.h"
60 #include "TString.h"
61 #include <TDatime.h>
62 #include <TRandom3.h>
63 #include <AliAODPid.h>
64 #include <AliAODHandler.h>
65 #include <AliAODRecoDecay.h>
66 #include <AliAODRecoDecayLF.h>
67 #include <AliAODRecoDecayLF2Prong.h>
68
69 ClassImp(AliAnalysisTaskReadNuclexAOD)
70
71 //________________________________________________________________________
72 AliAnalysisTaskReadNuclexAOD::AliAnalysisTaskReadNuclexAOD() 
73   : AliAnalysisTaskSE(),
74   fAnalysisType("AOD"), 
75   fCollidingSystems(0), 
76   fDataType("REAL"),
77   fListHist(0), 
78   fHistEventMultiplicity(0),         
79   fHistTrackMultiplicity(0),      
80   fHistTrackMultiplicityCent(0),      
81   fHistTrackMultiplicitySemiCent(0),  
82   fHistTrackMultiplicityMB(0),        
83   fHistTrackMultiplicityPVCent(0),      
84   fHistTrackMultiplicityPVSemiCent(0),  
85   fHistTrackMultiplicityPVMB(0),        
86   fhBB(0),
87   fhBBPions(0),
88   fhBBHe(0),
89   aodTree(0x0),
90   Nuclei(0x0),
91   SecondaryVertices(0x0),
92   DaughterTracks(0x0),
93   nevent(0x0),
94   fNtuple1(0),
95   trunNumber(0),
96   tbunchcross(0),
97   torbit(0),
98   tperiod(0),
99   teventtype(0),
100   tTrackNumber(0),
101   tpercentile(0),
102   txPrimaryVertex(0),
103   tyPrimaryVertex(0),
104   tzPrimaryVertex(0),
105   txSecondaryVertex(0),
106   tySecondaryVertex(0),
107   tzSecondaryVertex(0),
108   tdcaTracks(0),
109   tCosPointingAngle(0),
110   tDCAV0toPrimaryVertex(0),
111   tHeSign(0),
112   tHepInTPC(0),
113   tHeTPCsignal(0),
114   tDcaHeToPrimVertex(0),
115   tHeEta(0),
116   tmomHex(0),
117   tmomHey(0),
118   tmomHez(0),
119   tmomHeAtSVx(0),
120   tmomHeAtSVy(0),
121   tmomHeAtSVz(0),
122   tHeTPCNcls(0),
123   tHeimpactXY(0),
124   tHeimpactZ(0),
125   tHeITSClusterMap(0),
126   tIsHeITSRefit(0),
127   tPionSign(0),
128   tPionpInTPC(0),
129   tPionTPCsignal(0),
130   tDcaPionToPrimVertex(0),
131   tPionEta(0),
132   tmomPionx(0),
133   tmomPiony(0),
134   tmomPionz(0),
135   tmomNegPionAtSVx(0),
136   tmomNegPionAtSVy(0),
137   tmomNegPionAtSVz(0),
138   tPionTPCNcls(0),
139   tPionimpactXY(0),
140   tPionimpactZ(0),
141   tPionITSClusterMap(0),
142   tIsPiITSRefit(0),
143   txn(0),
144   txp(0),
145   tchi2He(0),
146   tchi2Pi(0),
147   fNtuple4(0),
148   t3LHlrunNumber(0),
149   t3LHlBCNumber(0),
150   t3LHlOrbitNumber(0),
151   t3LHlPeriodNumber(0),
152   t3LHleventtype(0),
153   t3LHlpercentile(0),
154   t3LHlPx(0),
155   t3LHlPy(0),
156   t3LHlPz(0),
157   t3LHlEta(0),
158   t3LHlY(0),
159   t3LHlM(0),
160   t3LHlxPrimaryVertex(0),
161   t3LHlyPrimaryVertex(0),
162   t3LHlzPrimaryVertex(0),
163   t3LHlp0px(0),    
164   t3LHlp0py(0),
165   t3LHlp0pz(0),
166   t3LHlp0ch(0),
167   t3LHlp1px(0),
168   t3LHlp1py(0),
169   t3LHlp1pz(0),
170   t3LHlp1ch(0)
171
172 {
173   // Dummy Constructor 
174 }
175
176 //________________________________________________________________________
177 AliAnalysisTaskReadNuclexAOD::AliAnalysisTaskReadNuclexAOD(const char *name) 
178   : AliAnalysisTaskSE(name), 
179     fAnalysisType("AOD"), 
180     fCollidingSystems(0), 
181     fDataType("REAL"),
182     fListHist(0), 
183     fHistEventMultiplicity(0),         
184     fHistTrackMultiplicity(0),      
185     fHistTrackMultiplicityCent(0),      
186     fHistTrackMultiplicitySemiCent(0),  
187     fHistTrackMultiplicityMB(0),        
188     fHistTrackMultiplicityPVCent(0),      
189     fHistTrackMultiplicityPVSemiCent(0),  
190     fHistTrackMultiplicityPVMB(0),        
191     fhBB(0),
192     fhBBPions(0),
193     fhBBHe(0),
194     aodTree(0x0),
195     Nuclei(0x0),
196     SecondaryVertices(0x0),
197     DaughterTracks(0x0),
198     nevent(0x0),
199     fNtuple1(0),
200     trunNumber(0),
201     tbunchcross(0),
202     torbit(0),
203     tperiod(0),
204     teventtype(0),
205     tTrackNumber(0),
206     tpercentile(0),
207     txPrimaryVertex(0),
208     tyPrimaryVertex(0),
209     tzPrimaryVertex(0),
210     txSecondaryVertex(0),
211     tySecondaryVertex(0),
212     tzSecondaryVertex(0),
213     tdcaTracks(0),
214     tCosPointingAngle(0),
215     tDCAV0toPrimaryVertex(0),
216     tHeSign(0),
217     tHepInTPC(0),
218     tHeTPCsignal(0),
219     tDcaHeToPrimVertex(0),
220     tHeEta(0),
221     tmomHex(0),
222     tmomHey(0),
223     tmomHez(0),
224     tmomHeAtSVx(0),
225     tmomHeAtSVy(0),
226     tmomHeAtSVz(0),
227     tHeTPCNcls(0),
228     tHeimpactXY(0),
229     tHeimpactZ(0),
230     tHeITSClusterMap(0),
231     tIsHeITSRefit(0),
232     tPionSign(0),
233     tPionpInTPC(0),
234     tPionTPCsignal(0),
235     tDcaPionToPrimVertex(0),
236     tPionEta(0),
237     tmomPionx(0),
238     tmomPiony(0),
239     tmomPionz(0),
240     tmomNegPionAtSVx(0),
241     tmomNegPionAtSVy(0),
242     tmomNegPionAtSVz(0),
243     tPionTPCNcls(0),
244     tPionimpactXY(0),
245     tPionimpactZ(0),
246     tPionITSClusterMap(0),
247     tIsPiITSRefit(0),
248     txn(0),
249     txp(0),
250     tchi2He(0),
251     tchi2Pi(0),
252     fNtuple4(0),
253     t3LHlrunNumber(0),
254     t3LHlBCNumber(0),
255     t3LHlOrbitNumber(0),
256     t3LHlPeriodNumber(0),
257     t3LHleventtype(0),
258     t3LHlpercentile(0),
259     t3LHlPx(0),
260     t3LHlPy(0),
261     t3LHlPz(0),
262     t3LHlEta(0),
263     t3LHlY(0),
264     t3LHlM(0),
265     t3LHlxPrimaryVertex(0),
266     t3LHlyPrimaryVertex(0),
267     t3LHlzPrimaryVertex(0),
268     t3LHlp0px(0),    
269     t3LHlp0py(0),
270     t3LHlp0pz(0),
271     t3LHlp0ch(0),
272     t3LHlp1px(0),
273     t3LHlp1py(0),
274     t3LHlp1pz(0),
275     t3LHlp1ch(0)
276
277 {
278   // Define input and output slots here
279   // Input slot #0 works with a TChain
280   //DefineInput(0, TChain::Class());
281   // Output slot #0 writes into a TList container (Cascade)
282   DefineOutput(1, TList::Class());
283   
284   DefineInput(0, TChain::Class());
285
286   DefineOutput(1, TList::Class());
287   DefineOutput(2, TTree::Class()); 
288   DefineOutput(3, TTree::Class()); 
289
290 }
291 //_______________________________________________________
292 AliAnalysisTaskReadNuclexAOD::~AliAnalysisTaskReadNuclexAOD() 
293
294   // Destructor
295   if (fListHist) {
296     delete fListHist;
297     fListHist = 0;
298   }
299   
300   if(fNtuple1) delete fNtuple1;
301   if(fNtuple4) delete fNtuple4;
302 }
303 //=================DEFINITION BETHE BLOCH==============================
304
305 Double_t AliAnalysisTaskReadNuclexAOD::BetheBloch(Double_t betaGamma,Double_t charge,Bool_t isPbPb) {
306
307   Double_t kp1, kp2, kp3, kp4, kp5;
308   
309   if(isPbPb){
310
311
312  
313     //pass2 2011
314     kp1 = 4.7*charge*charge;
315     kp2 = 8.98482806165147636e+00;
316     kp3 = 1.54000000000000005e-05;
317     kp4 = 2.30445734159456084e+00;
318     kp5 = 2.25624744086878559e+00;
319
320   }
321   
322   else{
323
324
325    //pass2 2011
326     kp1 = 4.7*charge*charge;
327     kp2 = 8.98482806165147636e+00;
328     kp3 = 1.54000000000000005e-05;
329     kp4 = 2.30445734159456084e+00;
330     kp5 = 2.25624744086878559e+00;
331
332  
333   }
334
335   Double_t beta = betaGamma / TMath::Sqrt(1.0 + betaGamma * betaGamma);
336   
337   Double_t aa = TMath::Power(beta, kp4);
338   Double_t bb = TMath::Power(1.0 / betaGamma, kp5);
339   
340   bb = TMath::Log(kp3 + bb);
341   
342   Double_t out = (kp2 - aa - bb) * kp1 / aa;
343
344   return out;
345  
346 }
347
348 void AliAnalysisTaskReadNuclexAOD::Init() 
349 {
350   //  cout<<"----------------------------------> Vediamo"<<endl;
351   
352   // AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
353   // cout<<aodHandler<<endl;
354   // TTree *aodTree = aodHandler->GetTree();
355   // //  aodTree = aodHandler->GetTree();
356   // cout<<"aodTree: "<<aodTree<<endl;
357   // aodTree->SetBranchAddress("Nuclei",           &Nuclei);
358   // aodTree->SetBranchAddress("SecondaryVertices",&SecondaryVertices);
359   // aodTree->SetBranchAddress("DaughterTracks",   &DaughterTracks);
360
361
362 }
363
364 //==================DEFINITION OF OUTPUT OBJECTS==============================
365
366 void AliAnalysisTaskReadNuclexAOD::UserCreateOutputObjects()
367 {
368   fListHist = new TList();
369   fListHist->SetOwner();  // IMPORTANT!
370
371   
372   if(! fHistEventMultiplicity ){
373     
374     fHistEventMultiplicity   = new TH1F( "fHistEventMultiplicity" , "Nb of Events" , 13 , 0, 13);
375      
376     fHistEventMultiplicity->GetXaxis()->SetBinLabel(1,"All Events");
377     fHistEventMultiplicity->GetXaxis()->SetBinLabel(2,"Events w/PV");
378     fHistEventMultiplicity->GetXaxis()->SetBinLabel(3,"Events w/|Vz|<10cm");
379     fHistEventMultiplicity->GetXaxis()->SetBinLabel(4,"Central Events");
380     fHistEventMultiplicity->GetXaxis()->SetBinLabel(5,"SemiCentral Events");
381     fHistEventMultiplicity->GetXaxis()->SetBinLabel(6,"MB Events");
382     fHistEventMultiplicity->GetXaxis()->SetBinLabel(7,"Central Events  w/|Vz|<10cm");
383     fHistEventMultiplicity->GetXaxis()->SetBinLabel(8,"SemiCentral Events  w/|Vz|<10cm");
384     fHistEventMultiplicity->GetXaxis()->SetBinLabel(9,"MB Events   w/|Vz|<10cm");
385     fHistEventMultiplicity->GetXaxis()->SetBinLabel(10,"Sec. Vert. Tree");
386     fHistEventMultiplicity->GetXaxis()->SetBinLabel(11,"Sec. Vert. Rec");
387     fHistEventMultiplicity->GetXaxis()->SetBinLabel(12,"Event Not taken");
388     fListHist->Add(fHistEventMultiplicity);
389   }
390
391   
392    if(! fHistTrackMultiplicity ){
393     fHistTrackMultiplicity   = new TH2F( "fHistTrackMultiplicity" , "Nb of Tracks", 2500,0, 25000,210,-1,104);
394     fHistTrackMultiplicity->GetXaxis()->SetTitle("Number of tracks");
395     fHistTrackMultiplicity->GetYaxis()->SetTitle("Percentile");
396     fListHist->Add(fHistTrackMultiplicity);
397   } 
398
399   if(! fHistTrackMultiplicityCent ){
400     fHistTrackMultiplicityCent   = new TH2F( "fHistTrackMultiplicityCent", "Nb of Tracks Central Events", 2500,0, 25000,210,-1,104 );
401     fHistTrackMultiplicityCent->GetXaxis()->SetTitle("Number of tracks");
402     fHistTrackMultiplicityCent->GetYaxis()->SetTitle("Percentile");
403     fListHist->Add(fHistTrackMultiplicityCent);
404   } 
405
406   if(! fHistTrackMultiplicitySemiCent ){
407     fHistTrackMultiplicitySemiCent   = new TH2F( "fHistTrackMultiplicitySemiCent" , "Nb of Tracks SemiCentral Events", 2500,0, 25000 ,210,-1,104);
408     fHistTrackMultiplicitySemiCent->GetXaxis()->SetTitle("Number of tracks");
409     fHistTrackMultiplicitySemiCent->GetYaxis()->SetTitle("Percentile");
410     fListHist->Add(fHistTrackMultiplicitySemiCent);
411   } 
412  
413   if(! fHistTrackMultiplicityMB ){
414     fHistTrackMultiplicityMB   = new TH2F( "fHistTrackMultiplicityMB" , "Nb of Tracks MBral Events", 2500,0, 25000,210,-1,104 );
415     fHistTrackMultiplicityMB->GetXaxis()->SetTitle("Number of tracks");
416     fHistTrackMultiplicityMB->GetYaxis()->SetTitle("Percentile");
417     fListHist->Add(fHistTrackMultiplicityMB);
418   } 
419
420   if(! fHistTrackMultiplicityPVCent ){
421     fHistTrackMultiplicityPVCent   = new TH2F( "fHistTrackMultiplicityPVCent" , "Nb of Tracks Central Events", 2500,0, 25000,210,-1,104 );
422     fHistTrackMultiplicityPVCent->GetXaxis()->SetTitle("Number of tracks");
423     fHistTrackMultiplicityPVCent->GetYaxis()->SetTitle("Percentile");
424     fListHist->Add(fHistTrackMultiplicityPVCent);
425   } 
426
427   if(! fHistTrackMultiplicityPVSemiCent ){
428     fHistTrackMultiplicityPVSemiCent   = new TH2F( "fHistTrackMultiplicityPVSemiCent" , "Nb of Tracks SemiCentral Events", 2500,0, 25000 ,210,-1,104);
429     fHistTrackMultiplicityPVSemiCent->GetXaxis()->SetTitle("Number of tracks");
430     fHistTrackMultiplicityPVSemiCent->GetYaxis()->SetTitle("Percentile");
431     fListHist->Add(fHistTrackMultiplicityPVSemiCent);
432   } 
433  
434   if(! fHistTrackMultiplicityPVMB ){
435     fHistTrackMultiplicityPVMB   = new TH2F( "fHistTrackMultiplicityPVMB" , "Nb of Tracks MBral Events", 2500,0, 25000,210,-1,104 );
436     fHistTrackMultiplicityPVMB->GetXaxis()->SetTitle("Number of tracks");
437     fHistTrackMultiplicityPVMB->GetYaxis()->SetTitle("Percentile");
438     fListHist->Add(fHistTrackMultiplicityPVMB);
439   } 
440
441   if(! fhBB ){
442     fhBB = new TH2F( "fhBB" , "BetheBlochTPC" , 120,-6,6,150,0,1500);
443     fhBB->GetXaxis()->SetTitle("p/z (GeV/#it{c})");
444     fhBB->GetYaxis()->SetTitle("TPC Signal");
445     fListHist->Add(fhBB);
446   }
447
448   if(! fhBBPions ){
449     fhBBPions = new TH2F( "fhBBPions" , "Bethe-Bloch TPC Pions" , 120,-6,6,150,0,1500);
450     fhBBPions->GetXaxis()->SetTitle("p/z (GeV/#it{c})");
451     fhBBPions->GetYaxis()->SetTitle("TPC Signal");
452     fListHist->Add(fhBBPions);
453   }
454   
455   if(! fhBBHe ){
456     fhBBHe = new TH2F( "fhBBHe" , "Bethe-Bloch TPC He" , 120,-6,6,150,0,1500);
457     fhBBHe->GetXaxis()->SetTitle("p/z (GeV/#it{c})");
458     fhBBHe->GetYaxis()->SetTitle("TPC Signal");
459     fListHist->Add(fhBBHe);
460   }
461   
462
463   
464   if(! fNtuple1 ) {
465     
466     fNtuple1 = new TTree("fNtuple1","fNtuple1");
467     
468     fNtuple1->Branch("trunNumber"           ,&trunNumber           ,"trunNumber/F");
469     fNtuple1->Branch("tbunchcross"          ,&tbunchcross          ,"tbunchcross/F");
470     fNtuple1->Branch("torbit"               ,&torbit               ,"torbit/F");
471     fNtuple1->Branch("tperiod"              ,&tperiod              ,"tperiod/F");
472     fNtuple1->Branch("teventtype"           ,&teventtype           ,"teventtype/F");
473     fNtuple1->Branch("tTrackNumber"         ,&tTrackNumber         ,"tTrackNumber/F");
474     fNtuple1->Branch("tpercentile"          ,&tpercentile          ,"tpercentile/F") ;
475     fNtuple1->Branch("txPrimaryVertex"      ,&txPrimaryVertex      ,"txPrimaryVertex/F");
476     fNtuple1->Branch("tyPrimaryVertex"      ,&tyPrimaryVertex      ,"tyPrimaryVertex/F");
477     fNtuple1->Branch("tzPrimaryVertex"      ,&tzPrimaryVertex      ,"tzPrimaryVertex/F");
478     fNtuple1->Branch("txSecondaryVertex"    ,&txSecondaryVertex    ,"txSecondaryVertex/F");
479     fNtuple1->Branch("tySecondaryVertex"    ,&tySecondaryVertex    ,"tySecondaryVertex/F");
480     fNtuple1->Branch("tzSecondaryVertex"    ,&tzSecondaryVertex    ,"tzSecondaryVertex/F");
481     fNtuple1->Branch("tdcaTracks"           ,&tdcaTracks           ,"tdcaTracks/F");
482     fNtuple1->Branch("tCosPointingAngle"    ,&tCosPointingAngle    ,"tCosPointingAngle/F");
483     fNtuple1->Branch("tDCAV0toPrimaryVertex",&tDCAV0toPrimaryVertex,"tDCAV0toPrimaryVertex/F");
484     fNtuple1->Branch("tHeSign"              ,&tHeSign              ,"tHeSign/F");
485     fNtuple1->Branch("tHepInTPC"            ,&tHepInTPC            ,"tHepInTPC/F");
486     fNtuple1->Branch("tHeTPCsignal"         ,&tHeTPCsignal         ,"tHeTPCsignal/F");
487     fNtuple1->Branch("tDcaHeToPrimVertex"   ,&tDcaHeToPrimVertex   ,"tDcaHeToPrimVertex/F");
488     fNtuple1->Branch("tHeEta"               ,&tHeEta               ,"tHeEta/F");
489     fNtuple1->Branch("tmomHex"              ,&tmomHex              ,"tmomHex/F");
490     fNtuple1->Branch("tmomHey"              ,&tmomHey              ,"tmomHey/F");
491     fNtuple1->Branch("tmomHez"              ,&tmomHez              ,"tmomHez/F");
492     fNtuple1->Branch("tmomHeAtSVx"          ,&tmomHeAtSVx          ,"tmomHeAtSVx/F");
493     fNtuple1->Branch("tmomHeAtSVy"          ,&tmomHeAtSVy          ,"tmomHeAtSVy/F");
494     fNtuple1->Branch("tmomHeAtSVz"          ,&tmomHeAtSVz          ,"tmomHeAtSVz/F");
495     fNtuple1->Branch("tHeTPCNcls"           ,&tHeTPCNcls           ,"tHeTPCNcls/F");
496     fNtuple1->Branch("tHeimpactXY"          ,&tHeimpactXY          ,"tHeimpactXY/F");
497     fNtuple1->Branch("tHeimpactZ"           ,&tHeimpactZ           ,"tHeimpactZ/F");
498     fNtuple1->Branch("tHeITSClusterMap"     ,&tHeITSClusterMap     ,"tHeITSClusterMap/F");
499     fNtuple1->Branch("tIsHeITSRefit"        ,&tIsHeITSRefit        ,"tIsHeITSRefit/F");
500     fNtuple1->Branch("tPionSign"            ,&tPionSign            ,"tPionSign/F");
501     fNtuple1->Branch("tPionpInTPC"          ,&tPionpInTPC          ,"tPionpInTPC/F");
502     fNtuple1->Branch("tPionTPCsignal"       ,&tPionTPCsignal       ,"tPionTPCsignal/F");
503     fNtuple1->Branch("tDcaPionToPrimVertex" ,&tDcaPionToPrimVertex ,"tDcaPionToPrimVertex/F");
504     fNtuple1->Branch("tPionEta"             ,&tPionEta             ,"tPionEta/F");
505     fNtuple1->Branch("tmomPionx"            ,&tmomPionx            ,"tmomPionx/F");
506     fNtuple1->Branch("tmomPiony"            ,&tmomPiony            ,"tmomPiony/F");
507     fNtuple1->Branch("tmomPionz"            ,&tmomPionz            ,"tmomPionz/F");
508     fNtuple1->Branch("tmomNegPionAtSVx"     ,&tmomNegPionAtSVx     ,"tmomNegPionAtSVx/F");
509     fNtuple1->Branch("tmomNegPionAtSVy"     ,&tmomNegPionAtSVy     ,"tmomNegPionAtSVy/F");
510     fNtuple1->Branch("tmomNegPionAtSVz"     ,&tmomNegPionAtSVz     ,"tmomNegPionAtSVz/F");
511     fNtuple1->Branch("tPionTPCNcls"         ,&tPionTPCNcls         ,"tPionTPCNcls/F");
512     fNtuple1->Branch("tPionimpactXY"        ,&tPionimpactXY        ,"tPionimpactXY/F");
513     fNtuple1->Branch("tPionimpactZ"         ,&tPionimpactZ         ,"tPionimpactZ/F");
514     fNtuple1->Branch("tPionITSClusterMap"   ,&tPionITSClusterMap   ,"tPionITSClusterMap/F");
515     fNtuple1->Branch("tIsPiITSRefit"        ,&tIsPiITSRefit        ,"tIsPiITSRefit/F");
516     fNtuple1->Branch("txn"                  ,&txn                  ,"txn/F");
517     fNtuple1->Branch("txp"                  ,&txp                  ,"txp/F");
518     fNtuple1->Branch("tchi2He"              ,&tchi2He              ,"tchi2He/F");
519     fNtuple1->Branch("tchi2Pi"              ,&tchi2Pi              ,"tchi2Pi/F");
520     
521   }
522
523    if(! fNtuple4 ) {
524  
525     fNtuple4 = new TTree("fNtuple4","fNtuple4");
526
527     fNtuple4->Branch("t3LHlrunNumber"        ,&t3LHlrunNumber        ,"t3LHlrunNumber/F");
528     fNtuple4->Branch("t3LHlBCNumber"         ,&t3LHlBCNumber         ,"t3LHlBCNumber/F");
529     fNtuple4->Branch("t3LHlOrbitNumber"      ,&t3LHlOrbitNumber      ,"t3LHlOrbitNumber/F");
530     fNtuple4->Branch("t3LHlPeriodNumber"     ,&t3LHlPeriodNumber     ,"t3LHlPeriodNumber/F");
531     fNtuple4->Branch("t3LHleventtype"        ,&t3LHleventtype        ,"t3LHleventtype/F");
532     fNtuple4->Branch("t3LHlpercentile"       ,&t3LHlpercentile       ,"t3LHlpercentile/F");
533     fNtuple4->Branch("t3LHlPx"               ,&t3LHlPx               ,"t3LHlPx/F");
534     fNtuple4->Branch("t3LHlPy"               ,&t3LHlPy               ,"t3LHlPy/F");
535     fNtuple4->Branch("t3LHlPz"               ,&t3LHlPz               ,"t3LHlPz/F");
536     fNtuple4->Branch("t3LHlEta"              ,&t3LHlEta              ,"t3LHlEta/F");
537     fNtuple4->Branch("t3LHlY"                ,&t3LHlY                ,"t3LHlY/F");
538     fNtuple4->Branch("t3LHlM"                ,&t3LHlM                ,"t3LHlM/F");
539     fNtuple4->Branch("t3LHlxPrimaryVertex"   ,&t3LHlxPrimaryVertex   ,"t3LHlxPrimaryVertex/F");
540     fNtuple4->Branch("t3LHlyPrimaryVertex"   ,&t3LHlyPrimaryVertex   ,"t3LHlyPrimaryVertex/F");
541     fNtuple4->Branch("t3LHlzPrimaryVertex"   ,&t3LHlzPrimaryVertex   ,"t3LHlzPrimaryVertex/F");
542     fNtuple4->Branch("t3LHlp0px"             ,&t3LHlp0px             ,"t3LHlp0px/F");
543     fNtuple4->Branch("t3LHlp0py"             ,&t3LHlp0py             ,"t3LHlp0py/F");
544     fNtuple4->Branch("t3LHlp0pz"             ,&t3LHlp0pz             ,"t3LHlp0pz/F");
545     fNtuple4->Branch("t3LHlp0ch"             ,&t3LHlp0ch             ,"t3LHlp0ch/F");
546     fNtuple4->Branch("t3LHlp1px"             ,&t3LHlp1px             ,"t3LHlp1px/F");
547     fNtuple4->Branch("t3LHlp1py"             ,&t3LHlp1py             ,"t3LHlp1py/F");
548     fNtuple4->Branch("t3LHlp1pz"             ,&t3LHlp1pz             ,"t3LHlp1pz/F");
549     fNtuple4->Branch("t3LHlp1ch"             ,&t3LHlp1ch             ,"t3LHlp1ch/F");
550
551
552   } 
553
554   
555   PostData(1,  fListHist);
556   PostData(2,  fNtuple1);
557   PostData(3,  fNtuple4);
558 }// end UserCreateOutputObjects
559
560
561
562 //====================== USER EXEC ========================
563
564 void AliAnalysisTaskReadNuclexAOD::UserExec(Option_t *) 
565 {
566   //_______________________________________________________________________
567
568   //!*********************!//
569   //!  Define variables   !//
570   //!*********************!//
571
572   Double_t  xPrimaryVertex=0.,yPrimaryVertex=0.,zPrimaryVertex=0.;
573
574   ULong_t  statusT;
575   ULong_t  statusPi;
576   
577   Bool_t   IsHeITSRefit=kFALSE,IsPiITSRefit=kFALSE ;
578
579   Double_t fPos[3]={0.,0.,0.};
580
581   Double_t runNumber=0.;
582   Double_t BCNumber=0.;
583   Double_t OrbitNumber=0.;
584   Double_t PeriodNumber=0.;
585
586   Double_t        Helium3Mass = 2.80839; 
587   Double_t        PionMass    = 0.13957; 
588
589   // TLORENTZ vectors
590   
591   TLorentzVector  vPion,vHelium,vSum;
592   TLorentzVector  vHyp;
593   TLorentzVector  vp0,vp1,vS;
594   //!----------------------------------------------------------------
595   //! A set of very loose parameters for cuts 
596   
597   //  Double_t fgChi2max=33.;     //! max chi2
598   Double_t fgDNmin=0.05;      //! min imp parameter for the 1st daughter = 500um
599   //  Double_t fgDPmin=0.05;      //! min imp parameter for the 2nd daughter = 500um
600   Double_t fgDCAmax=1.;       //! max DCA between the daughter tracks in cm
601   //  Double_t fgCPAmin=0.99;      //! min cosine of V0's pointing angle
602   Double_t fgRmin=0.1;        //! min radius of the fiducial volume = 1 mm 
603   Double_t fgRmax=200.;       //! max radius of the fiducial volume = 2 m
604   
605   //!-----------------------------------------------------------------
606
607   // Main loop
608   // Called for EACH event
609   
610   nevent++;  //--> This is important
611
612   AliVEvent *event = InputEvent();
613   if (!event) { Printf("ERROR: Could not retrieve event"); return; }
614   Info("AliAnalysisTaskReadNuclexAOD","Starting UserExec");  
615
616   SetDataType("REAL");
617   
618   AliAODEvent *lAODevent=(AliAODEvent *)InputEvent();   
619   if (!lAODevent) {
620     Printf("ERROR: aod not available");
621     //    fHistLog->Fill(98);
622     return;
623   }
624  
625   fHistEventMultiplicity->Fill(0.5);
626
627   //*************************************************************
628   
629   runNumber    = lAODevent->GetRunNumber();
630   BCNumber     = lAODevent->GetBunchCrossNumber();
631   OrbitNumber  = lAODevent->GetOrbitNumber();
632   PeriodNumber = lAODevent->GetPeriodNumber();
633    
634   AliCentrality *centrality = lAODevent->GetCentrality();
635   centrality = lAODevent->GetCentrality();
636     
637   Float_t percentile=centrality->GetCentralityPercentile("V0M");
638   Float_t refMult = lAODevent->GetHeader()->GetRefMultiplicity();
639   
640   fHistTrackMultiplicity->Fill(refMult,percentile); //tracce per evento
641
642   //  cout<<"Centrality: "<<percentile<<" number of track: "<<lAODevent->GetHeader()->GetRefMultiplicity()<<endl;
643   //*************************************************************
644   
645   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
646   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
647   
648   Int_t eventtype=-99;
649   
650   Bool_t isSelectedCentral     = (inputHandler->IsEventSelected() & AliVEvent::kCentral);
651   Bool_t isSelectedSemiCentral = (inputHandler->IsEventSelected() & AliVEvent::kSemiCentral);
652   Bool_t isSelectedMB          = (inputHandler->IsEventSelected() & AliVEvent::kMB);
653  
654   if(isSelectedCentral){
655     fHistEventMultiplicity->Fill(3.5);
656     fHistTrackMultiplicityCent->Fill(refMult,percentile); 
657     eventtype=1;
658   }
659
660   if(isSelectedSemiCentral){
661     fHistEventMultiplicity->Fill(4.5);
662     fHistTrackMultiplicitySemiCent->Fill(refMult,percentile); 
663     eventtype=2;
664   }
665
666   if(isSelectedMB){
667     fHistEventMultiplicity->Fill(5.5);
668     fHistTrackMultiplicityMB->Fill(refMult,percentile); 
669     eventtype=3;
670   }
671
672   if(eventtype==-99)return;
673   // cout<<"eventtype: "<<eventtype<<endl;
674   
675   // if(!isSelectedCentral)return;
676   // if(!isSelectedSemiCentral)return;
677   // if(!isSelectedMB)return;
678   
679   cout<<"eventtype: "<<eventtype<<endl;
680     
681   //-------------------------------
682   
683   Double_t lBestPrimaryVtxPos[3]          = {-100.0, -100.0, -100.0};
684   Double_t lMagneticField                 = -10.; 
685   
686   AliAODVertex* primvtx = lAODevent->GetPrimaryVertex();
687   if(!primvtx){
688     cout<<"No PV"<<endl;
689     return;
690   }
691   fHistEventMultiplicity->Fill(1.5);
692   primvtx->GetXYZ( lBestPrimaryVtxPos );
693
694   if(TMath::Abs(lBestPrimaryVtxPos[2]) > 10.0 ) { 
695     AliWarning("Pb / | Z position of Best Prim Vtx | > 10.0 cm ... return !"); 
696     return; 
697   }
698   fHistEventMultiplicity->Fill(2.5);
699
700
701   if(eventtype==1){
702     fHistTrackMultiplicityPVCent->Fill(refMult,percentile); 
703     fHistEventMultiplicity->Fill(6.5); 
704   }
705   
706   if(eventtype==2){
707     fHistTrackMultiplicityPVSemiCent->Fill(refMult,percentile); 
708     fHistEventMultiplicity->Fill(7.5); 
709   }
710   
711   if(eventtype==3){
712     fHistTrackMultiplicityPVMB->Fill(refMult,percentile); 
713     fHistEventMultiplicity->Fill(8.5); 
714   }
715   
716   lMagneticField = lAODevent->GetMagneticField();
717
718   xPrimaryVertex = lBestPrimaryVtxPos[0];
719   yPrimaryVertex = lBestPrimaryVtxPos[1];
720   zPrimaryVertex = lBestPrimaryVtxPos[2];
721
722   //--------------------------------------------------------
723
724   AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
725
726   aodTree = aodHandler->GetTree();
727   aodTree->SetBranchAddress("Nuclei",&Nuclei);
728   aodTree->SetBranchAddress("SecondaryVertices",&SecondaryVertices);
729   aodTree->SetBranchAddress("DaughterTracks",&DaughterTracks);
730
731   //---------------------------------------------------------
732
733   aodTree->GetEntry(nevent);
734
735   if(Nuclei-> GetEntriesFast()>0)
736     fHistEventMultiplicity->Fill(2);
737
738   if(SecondaryVertices-> GetEntriesFast()>0)
739     fHistEventMultiplicity->Fill(3);
740     
741   for(Int_t i=0; i < SecondaryVertices-> GetEntriesFast() ; i++){
742
743     AliAODRecoDecayLF2Prong *d = (AliAODRecoDecayLF2Prong*)SecondaryVertices->UncheckedAt(i);
744     //cout<<"\n\n\nPT: "<<d->Pt()<<endl<<endl<<endl<<endl;
745     if(!d) continue;
746    
747     fHistEventMultiplicity->Fill(10.5);
748     
749     //    Double_t tDecayVertexV0[3]; 
750     // if(d->GetXYZ(tDecayVertexV0))
751     
752     Double_t tV0mom[3];
753     d->PxPyPz(tV0mom); 
754     
755     // TLORENTZ vectors
756
757     //    cout<<"px prong 1: "<<d->PxProng(0)<<endl;
758
759     vHyp.SetXYZM(tV0mom[0],tV0mom[1],tV0mom[2],2.991);
760     
761
762     vp0.SetXYZM(d->PxProng(0),d->PyProng(0),d->PzProng(0),PionMass);
763     vp1.SetXYZM(d->PxProng(1),d->PyProng(1),d->PzProng(1),Helium3Mass);
764     vS = vp0 + vp1;
765
766     //    cout<<"Momemnto pt: "<<lPt<<endl;
767     
768     t3LHlrunNumber         =(Float_t)runNumber;
769     t3LHlBCNumber          =(Float_t)BCNumber;
770     t3LHlOrbitNumber       =(Float_t)OrbitNumber;
771     t3LHlPeriodNumber      =(Float_t)PeriodNumber;
772     t3LHleventtype         =(Float_t)eventtype;
773     t3LHlpercentile        =(Float_t)percentile;
774     t3LHlPx                =(Float_t)tV0mom[0];
775     t3LHlPy                =(Float_t)tV0mom[1];
776     t3LHlPz                =(Float_t)tV0mom[2];
777     t3LHlEta               =(Float_t)d->Eta();
778     t3LHlY                 =(Float_t)vHyp.Rapidity();
779     t3LHlM                 =(Float_t)vS.M();
780     t3LHlxPrimaryVertex    =(Float_t)xPrimaryVertex;
781     t3LHlyPrimaryVertex    =(Float_t)yPrimaryVertex;
782     t3LHlzPrimaryVertex    =(Float_t)zPrimaryVertex;
783
784     t3LHlp0px    =(Float_t)d->PxProng(0);
785     t3LHlp0py    =(Float_t)d->PyProng(0);
786     t3LHlp0pz    =(Float_t)d->PzProng(0);
787     t3LHlp0ch    =(Float_t)d->ChargeProng(0);
788     t3LHlp1px    =(Float_t)d->PxProng(1);
789     t3LHlp1py    =(Float_t)d->PyProng(1);
790     t3LHlp1pz    =(Float_t)d->PzProng(1);
791     t3LHlp1ch    =(Float_t)d->ChargeProng(1);
792
793     fNtuple4->Fill();
794     
795   }
796   
797   
798   //----------------------------------------
799   // Loop on tracks like-AnalysisTaskHelium3Pi.cxx
800   
801   Int_t TrackNumber= DaughterTracks-> GetEntriesFast();
802
803   TArrayI Track0(TrackNumber);        //Pions                                                                          
804   Int_t nTrack0=0;
805  
806   TArrayI Track1(TrackNumber);        //Helium3
807   Int_t nTrack1=0;
808  
809
810   Float_t impactXY=-999, impactZ=-999;
811   Float_t impactXYpi=-999, impactZpi=-999;
812   
813   for(Int_t j=0; j<TrackNumber; j++){
814     //  cout<<"eventtype inside: "<<eventtype<<endl;
815     //    cout<<"Inside loop tracks"<<endl;
816     AliVTrack *track = (AliVTrack*)DaughterTracks->UncheckedAt(j);
817     AliAODTrack *aodtrack =(AliAODTrack*)track;
818     
819     fhBB->Fill(aodtrack->GetDetPid()->GetTPCmomentum()*aodtrack->Charge(),aodtrack->GetTPCsignal());
820     
821     //-----------------------------------------------------------
822     //Track cuts
823     // if(aodtrack->GetTPCNcls() < 80 )continue;
824     // if(aodtrack->Chi2perNDF() > 5 )continue;
825
826     // if (!aodtrack->IsOn(AliAODTrack::kTPCrefit)) continue;
827     // if (!aodtrack->IsOn(AliAODTrack::kTPCin)) continue;
828     // if (aodtrack->IsOn(AliAODTrack::kITSpureSA)) continue;
829
830     //---------------------------------------------------------------
831      
832     if (aodtrack->GetTPCsignal()<100){
833       Track0[nTrack0++]=j;
834       fhBBPions->Fill(aodtrack->GetDetPid()->GetTPCmomentum()*aodtrack->Charge(),aodtrack->GetTPCsignal());
835     }
836
837     else{
838       Track1[nTrack1++]=j;
839       fhBBHe->Fill(aodtrack->GetDetPid()->GetTPCmomentum()*aodtrack->Charge(),aodtrack->GetTPCsignal());
840     }
841  
842   }
843
844   Track0.Set(nTrack0);
845   Track1.Set(nTrack1);
846  
847
848   //cout<<"nTrack0: "<<nTrack0<<endl;
849   //cout<<"nTrack1: "<<nTrack1<<endl;
850   
851   
852   //cout<<"Track loops..."<<endl;
853    
854   Double_t        DcaHeToPrimVertex=0;
855   Double_t        DcaPionToPrimVertex=0;
856   
857   impactXY=-999, impactZ=-999;
858   impactXYpi=-999, impactZpi=-999;
859   
860  
861   AliESDtrack  *PionTrack = 0x0;
862   AliESDtrack  *HeTrack = 0x0;
863
864
865   // Vettors for il PxPyPz
866   
867   Double_t momPionVett[3];
868   for(Int_t i=0;i<3;i++)momPionVett[i]=0;
869   
870   Double_t momHeVett[3];
871   for(Int_t i=0;i<3;i++)momHeVett[i]=0;
872   
873   //At SV
874   
875   Double_t momPionVettAt[3];
876   for(Int_t i=0;i<3;i++)momPionVettAt[i]=0;
877   
878   Double_t momHeVettAt[3];
879   for(Int_t i=0;i<3;i++)momHeVettAt[i]=0;
880   
881
882   //Loop on the tracks
883
884   for (Int_t k=0; k <nTrack0 ; k++) {                           //! Pion Tracks Loop
885
886     DcaPionToPrimVertex=0.;
887     DcaHeToPrimVertex=0;
888     
889     Int_t Track0idx=Track0[k];
890     
891     AliVTrack *trackpi = (AliVTrack*)DaughterTracks->UncheckedAt(Track0idx);
892     PionTrack = new AliESDtrack(trackpi); 
893     
894     statusPi = (ULong_t)trackpi->GetStatus();
895     IsPiITSRefit = ((statusPi) & (AliESDtrack::kITSrefit)); 
896     
897     if (PionTrack) 
898       DcaPionToPrimVertex = TMath::Abs(PionTrack->GetD(xPrimaryVertex, yPrimaryVertex,lMagneticField));
899
900     //cout<<"DcaPionToPrimVertex: "<<DcaPionToPrimVertex<<endl;
901
902     if(DcaPionToPrimVertex<0.2)continue; 
903     AliExternalTrackParam trackInPion(*PionTrack);  
904
905     for (Int_t i=0; i<nTrack1; i++){                            //! He Tracks Loop
906       
907       Int_t Track1idx=Track1[i];
908       
909       AliVTrack *trackhe = (AliVTrack*)DaughterTracks->UncheckedAt(Track1idx);
910       HeTrack = new AliESDtrack(trackhe);
911       
912       statusT= (ULong_t)HeTrack->GetStatus();
913       IsHeITSRefit = (statusT & AliESDtrack::kITSrefit); 
914
915       if (HeTrack) 
916         DcaHeToPrimVertex = TMath::Abs(HeTrack->GetD(xPrimaryVertex, yPrimaryVertex,lMagneticField)); //OK
917       
918       AliExternalTrackParam trackInHe(*HeTrack); 
919     
920       if ( DcaPionToPrimVertex < fgDNmin)                //OK
921         if ( DcaHeToPrimVertex < fgDNmin) continue;    //OK
922       
923       Double_t xn, xp;
924       Double_t dca=0.;
925       
926       dca= PionTrack->GetDCA(HeTrack,lMagneticField,xn,xp); //!dca (Neg to Pos)
927       
928       //cout<<"dca tracks: "<<dca<<endl;
929
930       if (dca > fgDCAmax) continue;
931       if ((xn+xp) > 2*fgRmax) continue;
932       if ((xn+xp) < 2*fgRmin) continue;
933       
934         Bool_t corrected=kFALSE;
935         if ((trackInPion.GetX() > 3.) && (xn < 3.)) {
936           //correct for the beam pipe material
937           corrected=kTRUE;
938         }
939         if ((trackInHe.GetX() > 3.) && (xp < 3.)) {
940           //correct for the beam pipe material
941           corrected=kTRUE;
942         }
943         if (corrected) {
944           dca=trackInPion.GetDCA(&trackInHe,lMagneticField,xn,xp);
945           if (dca > fgDCAmax) continue;
946           if ((xn+xp) > 2*fgRmax) continue;
947           if ((xn+xp) < 2*fgRmin) continue;
948         }
949         
950         //=============================================//
951         // Make "V0" with found tracks                 //
952         //=============================================//
953         
954         trackInPion.PropagateTo(xn,lMagneticField); 
955         trackInHe.PropagateTo(xp,lMagneticField);
956         
957         AliESDv0 vertex(trackInPion,Track0idx,trackInHe,Track1idx);
958         //      if (vertex.GetChi2V0() > fgChi2max) continue;
959         
960         //cout<<"Made v0"<<endl;
961
962         Float_t CosPointingAngle=vertex.GetV0CosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex); //PointingAngle
963         //cout<<"cpa: "<<CosPointingAngle<<endl;
964         //      if (CosPointingAngle < fgCPAmin) continue;
965         
966         vertex.SetDcaV0Daughters(dca);
967         vertex.SetV0CosineOfPointingAngle(CosPointingAngle);
968         
969         fPos[0]=vertex.Xv();
970         fPos[1]=vertex.Yv(); 
971         fPos[2]=vertex.Zv(); 
972         
973         HeTrack->PxPyPz(momHeVett);
974         PionTrack->PxPyPz(momPionVett); 
975         
976         Double_t raggio=TMath::Sqrt(fPos[0]*fPos[0]+fPos[1]*fPos[1]+fPos[2]*fPos[2]);
977         HeTrack->GetPxPyPzAt(raggio,lMagneticField,momHeVettAt);
978         PionTrack->GetPxPyPzAt(raggio,lMagneticField,momPionVettAt); 
979         
980         //------------------------------------------------------------------------//
981         
982         HeTrack->GetImpactParameters(impactXY, impactZ);
983         PionTrack->GetImpactParameters(impactXYpi, impactZpi);
984         
985         //      if(vertex.GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex)>3) continue;
986         
987         //salvo solo fino a 3.1 GeV/c2
988         
989         vHelium.SetXYZM(2*momHeVettAt[0],2*momHeVettAt[1],2*momHeVettAt[2],Helium3Mass); 
990         vPion.SetXYZM(momPionVettAt[0],momPionVettAt[1],momPionVettAt[2],PionMass);       
991         vSum=vHelium+vPion;
992         
993         //      if(vSum.M()>3.2)
994         //  continue;
995         
996         Int_t  fIdxInt[200]; //dummy array
997         Int_t nClustersTPCHe = HeTrack->GetTPCclusters(fIdxInt);
998         Int_t nClustersTPCPi = PionTrack->GetTPCclusters(fIdxInt);
999         
1000         //cout<<"Cos PA: "<<CosPointingAngle<<endl;
1001         fHistEventMultiplicity->Fill(11.5);
1002         //-------------------------------------------------------------
1003         
1004         trunNumber              =(Float_t)runNumber;
1005         tbunchcross             =(Float_t)BCNumber;
1006         torbit                  =(Float_t)OrbitNumber;
1007         tperiod                 =(Float_t)PeriodNumber;
1008         teventtype              =(Float_t)eventtype;
1009         tTrackNumber            =(Float_t)TrackNumber;
1010         tpercentile             =(Float_t)percentile;
1011         txPrimaryVertex         =(Float_t)xPrimaryVertex;            //PRIMARY
1012         tyPrimaryVertex         =(Float_t)yPrimaryVertex;
1013         tzPrimaryVertex         =(Float_t)zPrimaryVertex;
1014         txSecondaryVertex       =(Float_t)fPos[0];                   //SECONDARY
1015         tySecondaryVertex       =(Float_t)fPos[1];
1016         tzSecondaryVertex       =(Float_t)fPos[2];
1017         tdcaTracks              =(Float_t)dca;                       //between 2 tracks
1018         tCosPointingAngle       =(Float_t)CosPointingAngle;          //cosPointingAngle da V0
1019         tDCAV0toPrimaryVertex   =(Float_t)vertex.GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
1020         tHeSign                 =(Float_t)HeTrack->GetSign();        //He
1021         tHepInTPC               =(Float_t)trackInHe.GetP();
1022         tHeTPCsignal            =(Float_t)HeTrack->GetTPCsignal();
1023         tDcaHeToPrimVertex      =(Float_t)DcaHeToPrimVertex;
1024         tHeEta                  =(Float_t)HeTrack->Eta();
1025         tmomHex                 =(Float_t)momHeVett[0];
1026         tmomHey                 =(Float_t)momHeVett[1];
1027         tmomHez                 =(Float_t)momHeVett[2];
1028         tmomHeAtSVx             =(Float_t)momHeVettAt[0];
1029         tmomHeAtSVy             =(Float_t)momHeVettAt[1];
1030         tmomHeAtSVz             =(Float_t)momHeVettAt[2];
1031         tHeTPCNcls              =(Float_t)HeTrack->GetTPCNcls();
1032         tHeimpactXY             =(Float_t)impactXY;
1033         tHeimpactZ              =(Float_t)impactZ;
1034         tHeITSClusterMap        =(Float_t)HeTrack->GetITSClusterMap();
1035         tIsHeITSRefit           =(Float_t)IsHeITSRefit;
1036         tPionSign               =(Float_t)PionTrack->GetSign(); //Pion
1037         tPionpInTPC             =(Float_t)trackInPion.GetP();
1038         tPionTPCsignal          =(Float_t)PionTrack->GetTPCsignal();
1039         tDcaPionToPrimVertex    =(Float_t)DcaPionToPrimVertex;
1040         tPionEta                =(Float_t)PionTrack->Eta();
1041         tmomPionx               =(Float_t)momPionVett[0];
1042         tmomPiony               =(Float_t)momPionVett[1];
1043         tmomPionz               =(Float_t)momPionVett[2];
1044         tmomNegPionAtSVx        =(Float_t)momPionVettAt[0];
1045         tmomNegPionAtSVy        =(Float_t)momPionVettAt[1];
1046         tmomNegPionAtSVz        =(Float_t)momPionVettAt[2];
1047         tPionTPCNcls            =(Float_t)PionTrack->GetTPCNcls();
1048         tPionimpactXY           =(Float_t)impactXYpi;
1049         tPionimpactZ            =(Float_t)impactZpi;
1050         tPionITSClusterMap      =(Float_t)PionTrack->GetITSClusterMap();
1051         tIsPiITSRefit           =(Float_t)IsPiITSRefit;
1052         txn                     =(Float_t)xn;
1053         txp                     =(Float_t)xp;
1054         tchi2He                 =(Float_t)HeTrack->GetTPCchi2()/(Float_t)(nClustersTPCHe);
1055         tchi2Pi                 =(Float_t)PionTrack->GetTPCchi2()/(Float_t)(nClustersTPCPi);
1056         
1057         fNtuple1->Fill();  
1058         vertex.Delete();
1059                 
1060     }    
1061     
1062   }
1063   
1064   PostData(1,fListHist);
1065   PostData(2,fNtuple1);
1066   PostData(3,fNtuple4);
1067     
1068 } //end userexec
1069
1070
1071 //________________________________________________________________________
1072
1073 void AliAnalysisTaskReadNuclexAOD::Terminate(Option_t *) 
1074 {
1075   // Draw result to the screen
1076   // Called once at the end of the query
1077 }
1078
1079