1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
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 * appear 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 **************************************************************************/
16 * Class for reading V0's
19 // --- ROOT system ---
23 //---- ANALYSIS system ----
24 #include "AliV0Reader.h"
25 #include "AliAnalysisManager.h"
26 #include "AliESDInputHandler.h"
28 #include "AliMCEvent.h"
29 #include "AliKFVertex.h"
38 AliV0Reader::AliV0Reader() :
40 fCurrentEventGoodV0s(),
41 fPreviousEventGoodV0s(),
48 fCurrentV0IndexNumber(0),
50 fCurrentNegativeKFParticle(NULL),
51 fCurrentPositiveKFParticle(NULL),
52 fCurrentMotherKFCandidate(NULL),
53 fCurrentNegativeESDTrack(NULL),
54 fCurrentPositiveESDTrack(NULL),
55 fNegativeTrackLorentzVector(NULL),
56 fPositiveTrackLorentzVector(NULL),
57 fMotherCandidateLorentzVector(NULL),
63 fNegativeMCParticle(NULL),
64 fPositiveMCParticle(NULL),
65 fMotherMCParticle(NULL),
66 fMotherCandidateKFMass(0),
67 fMotherCandidateKFWidth(0),
68 fUseKFParticle(kTRUE),
71 fMaxR(10000),// 100 meter(outside of ALICE)
75 fPIDProbabilityCutNegativeParticle(0),
76 fPIDProbabilityCutPositiveParticle(0),
81 fUseImprovedVertex(kFALSE)
87 AliV0Reader::AliV0Reader(const AliV0Reader & original) :
89 fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),
90 fPreviousEventGoodV0s(original.fPreviousEventGoodV0s),
91 fMCStack(original.fMCStack),
92 fMCTruth(original.fMCTruth),
93 fChain(original.fChain),
94 fESDHandler(original.fESDHandler),
95 fESDEvent(original.fESDEvent),
96 fHistograms(original.fHistograms),
97 fCurrentV0IndexNumber(original.fCurrentV0IndexNumber),
98 fCurrentV0(original.fCurrentV0),
99 fCurrentNegativeKFParticle(original.fCurrentNegativeKFParticle),
100 fCurrentPositiveKFParticle(original.fCurrentPositiveKFParticle),
101 fCurrentMotherKFCandidate(original.fCurrentMotherKFCandidate),
102 fCurrentNegativeESDTrack(original.fCurrentNegativeESDTrack),
103 fCurrentPositiveESDTrack(original.fCurrentPositiveESDTrack),
104 fNegativeTrackLorentzVector(original.fNegativeTrackLorentzVector),
105 fPositiveTrackLorentzVector(original.fPositiveTrackLorentzVector),
106 fMotherCandidateLorentzVector(original.fMotherCandidateLorentzVector),
107 fCurrentXValue(original.fCurrentXValue),
108 fCurrentYValue(original.fCurrentYValue),
109 fCurrentZValue(original.fCurrentZValue),
110 fPositiveTrackPID(original.fPositiveTrackPID),
111 fNegativeTrackPID(original.fNegativeTrackPID),
112 fNegativeMCParticle(original.fNegativeMCParticle),
113 fPositiveMCParticle(original.fPositiveMCParticle),
114 fMotherMCParticle(original.fMotherMCParticle),
115 fMotherCandidateKFMass(original.fMotherCandidateKFMass),
116 fMotherCandidateKFWidth(original.fMotherCandidateKFWidth),
117 fUseKFParticle(kTRUE),
118 fUseESDTrack(kFALSE),
120 fMaxR(original.fMaxR),
121 fEtaCut(original.fEtaCut),
122 fPtCut(original.fPtCut),
123 fChi2Cut(original.fChi2Cut),
124 fPIDProbabilityCutNegativeParticle(original.fPIDProbabilityCutNegativeParticle),
125 fPIDProbabilityCutPositiveParticle(original.fPIDProbabilityCutPositiveParticle),
126 fXVertexCut(original.fXVertexCut),
127 fYVertexCut(original.fYVertexCut),
128 fZVertexCut(original.fZVertexCut),
129 fNSigmaMass(original.fNSigmaMass),
130 fUseImprovedVertex(original.fUseImprovedVertex)
136 AliV0Reader & AliV0Reader::operator = (const AliV0Reader & /*source*/)
138 // assignment operator
142 void AliV0Reader::Initialize(){
143 // Get the input handler from the manager
144 fESDHandler = (AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
145 if(fESDHandler == NULL){
149 // Get pointer to esd event from input handler
150 fESDEvent = fESDHandler->GetEvent();
151 if(fESDEvent == NULL){
155 //Get pointer to MCTruth
156 fMCTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
157 if(fMCTruth == NULL){
161 //Get pointer to the mc stack
162 fMCStack = fMCTruth->MCEvent()->Stack();
163 if(fMCStack == NULL){
167 AliKFParticle::SetField(fESDEvent->GetMagneticField());
171 AliESDv0* AliV0Reader::GetV0(Int_t index){
172 fCurrentV0 = fESDEvent->GetV0(index);
173 UpdateV0Information();
178 Bool_t AliV0Reader::NextV0(){
179 Bool_t iResult=kFALSE;
180 while(fCurrentV0IndexNumber<fESDEvent->GetNumberOfV0s()){
181 fCurrentV0 = fESDEvent->GetV0(fCurrentV0IndexNumber);
183 //checks if on the fly mode is set
184 if ( !fCurrentV0->GetOnFlyStatus() ){
185 fCurrentV0IndexNumber++;
186 if(fHistograms->fV0MassDebugCut1){fHistograms->fV0MassDebugCut1->Fill(GetMotherCandidateMass());}
190 if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {//checks if we have a vertex
191 fCurrentV0IndexNumber++;
192 if(fHistograms->fV0MassDebugCut2){fHistograms->fV0MassDebugCut2->Fill(GetMotherCandidateMass());}
196 if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){
197 fCurrentV0IndexNumber++;
198 if(fHistograms->fV0MassDebugCut3){fHistograms->fV0MassDebugCut3->Fill(GetMotherCandidateMass());}
203 fCurrentV0->GetXYZ(fCurrentXValue,fCurrentYValue,fCurrentZValue);
205 if(GetXYRadius()>fMaxR){ // cuts on distance from collision point
206 fCurrentV0IndexNumber++;
207 if(fHistograms->fV0MassDebugCut4){fHistograms->fV0MassDebugCut4->Fill(GetMotherCandidateMass());}
211 UpdateV0Information();
214 if(fCurrentMotherKFCandidate->GetNDF()<=0){
215 fCurrentV0IndexNumber++;
216 if(fHistograms->fV0MassDebugCut5){fHistograms->fV0MassDebugCut5->Fill(GetMotherCandidateMass());}
219 Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();
220 if(chi2V0 > fChi2Cut || chi2V0 <=0){
221 fCurrentV0IndexNumber++;
222 if(fHistograms->fV0MassDebugCut6){fHistograms->fV0MassDebugCut6->Fill(GetMotherCandidateMass());}
226 if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){
227 fCurrentV0IndexNumber++;
228 if(fHistograms->fV0MassDebugCut7){fHistograms->fV0MassDebugCut7->Fill(GetMotherCandidateMass());}
232 if(fMotherCandidateLorentzVector->Pt()<fPtCut){
233 fCurrentV0IndexNumber++;
234 if(fHistograms->fV0MassDebugCut8){fHistograms->fV0MassDebugCut8->Fill(GetMotherCandidateMass());}
239 else if(fUseESDTrack){
243 iResult=kTRUE;//means we have a v0 who survived all the cuts applied
245 fCurrentV0IndexNumber++;
252 void AliV0Reader::UpdateV0Information(){
253 if(fCurrentNegativeKFParticle != NULL){
254 delete fCurrentNegativeKFParticle;
255 // fCurrentNegativeKFParticle = NULL;
257 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fNegativeTrackPID);
259 if(fCurrentPositiveKFParticle != NULL){
260 delete fCurrentPositiveKFParticle;
261 // fCurrentPositiveKFParticle = NULL;
263 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fPositiveTrackPID);
265 if(fCurrentMotherKFCandidate != NULL){
266 // cout<<"fCurrentMotherKFCandidate: "<<fCurrentMotherKFCandidate<<endl;
267 delete fCurrentMotherKFCandidate;
268 // fCurrentMotherKFCandidate = NULL;
270 fCurrentMotherKFCandidate = new AliKFParticle(*fCurrentNegativeKFParticle,*fCurrentPositiveKFParticle);
272 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
274 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
276 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
277 fCurrentMotherKFCandidate->SetMassConstraint(0,fNSigmaMass);
280 if(fUseImprovedVertex == kTRUE){
281 AliKFVertex primaryVertexImproved(*GetPrimaryVertex());
282 primaryVertexImproved+=*fCurrentMotherKFCandidate;
283 fCurrentMotherKFCandidate->SetProductionVertex(primaryVertexImproved);
286 fCurrentMotherKFCandidate->GetMass(fMotherCandidateKFMass,fMotherCandidateKFWidth);
289 if(fNegativeTrackLorentzVector != NULL){
290 delete fNegativeTrackLorentzVector;
293 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeKFParticle->Px(),fCurrentNegativeKFParticle->Py(),fCurrentNegativeKFParticle->Pz());
295 else if(fUseESDTrack){
296 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeESDTrack->Px(),fCurrentNegativeESDTrack->Py(),fCurrentNegativeESDTrack->Pz());
299 if(fPositiveTrackLorentzVector != NULL){
300 delete fPositiveTrackLorentzVector;
303 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveKFParticle->Px(),fCurrentPositiveKFParticle->Py(),fCurrentPositiveKFParticle->Pz());
305 else if(fUseESDTrack){
306 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveESDTrack->Px(),fCurrentPositiveESDTrack->Py(),fCurrentPositiveESDTrack->Pz());
309 if(fMotherCandidateLorentzVector != NULL){
310 delete fMotherCandidateLorentzVector;
313 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
314 // new TLorentzVector(fCurrentMotherKFCandidate->Px(),fCurrentMotherKFCandidate->Py(),fCurrentMotherKFCandidate->Pz());
316 else if(fUseESDTrack){
317 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
318 // new TLorentzVector(fCurrentNegativeESDTrack->Px()+fCurrentPositiveESDTrack->Px(),fCurrentNegativeESDTrack->Py()+fCurrentPositiveESDTrack->Py(),fCurrentNegativeESDTrack->Pz()+fCurrentPositiveESDTrack->Pz());
321 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
322 fMotherCandidateLorentzVector->SetXYZM(fMotherCandidateLorentzVector->Px() ,fMotherCandidateLorentzVector->Py(),fMotherCandidateLorentzVector->Pz(),0.);
326 fNegativeMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));
327 fPositiveMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetPindex())->GetLabel()));
331 Bool_t AliV0Reader::HasSameMCMother(){
332 Bool_t iResult = kFALSE;
334 if(fNegativeMCParticle != NULL && fPositiveMCParticle != NULL){
335 if(fNegativeMCParticle->GetMother(0) == fPositiveMCParticle->GetMother(0))
336 fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));
343 AliKFParticle* AliV0Reader::GetNegativeKFParticle(){
344 return fCurrentNegativeKFParticle;
347 AliKFParticle* AliV0Reader::GetPositiveKFParticle(){
348 return fCurrentPositiveKFParticle;
351 AliKFParticle* AliV0Reader::GetMotherCandidateKFCombination(){
352 return fCurrentMotherKFCandidate;
355 Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut){
356 Bool_t iResult=kFALSE;
358 Double_t *posProbArray = new Double_t[10];
359 Double_t *negProbArray = new Double_t[10];
360 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
361 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
363 negTrack->GetTPCpid(negProbArray);
364 posTrack->GetTPCpid(posProbArray);
366 if(negProbArray!=NULL && posProbArray!=NULL){
367 if(negProbArray[GetSpeciesIndex(-1)]>=negProbCut && posProbArray[GetSpeciesIndex(1)]>=posProbCut){
371 delete [] posProbArray;
372 delete [] negProbArray;
376 void AliV0Reader::UpdateEventByEventData(){
377 fPreviousEventGoodV0s.clear();
378 fPreviousEventGoodV0s = fCurrentEventGoodV0s;
379 fCurrentEventGoodV0s.clear();
381 fCurrentV0IndexNumber=0;
384 Double_t AliV0Reader::GetNegativeTrackPhi(){
386 if(fNegativeTrackLorentzVector->Phi()> TMath::Pi()){
387 offset = -2*TMath::Pi();
389 return fNegativeTrackLorentzVector->Phi()+offset;
392 Double_t AliV0Reader::GetPositiveTrackPhi(){
394 if(fPositiveTrackLorentzVector->Phi()> TMath::Pi()){
395 offset = -2*TMath::Pi();
397 return fPositiveTrackLorentzVector->Phi()+offset;
400 Double_t AliV0Reader::GetMotherCandidatePhi(){
402 if(fMotherCandidateLorentzVector->Phi()> TMath::Pi()){
403 offset = -2*TMath::Pi();
405 return fMotherCandidateLorentzVector->Phi()+offset;
408 Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
410 Int_t iResult = 10; // Unknown particle
412 if(chargeOfTrack==-1){ //negative track
413 switch(abs(fNegativeTrackPID)){
442 //Put in here for kSPECIES::kEleCon ????
445 else if(chargeOfTrack==1){ //positive track
446 switch(abs(fPositiveTrackPID)){
475 //Put in here for kSPECIES::kEleCon ????
479 //Wrong parameter.. Print warning