1 /**************************************************************************
\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
\r
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
\r
7 * Permission to use, copy, modify and distribute this software and its *
\r
8 * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * without fee, provided that the above copyright notice appears in all *
\r
10 * copies and that both the copyright notice and this permission notice *
\r
11 * appear in the supporting documentation. The authors make no claims *
\r
12 * about the suitability of this software for any purpose. It is *
\r
13 * provided "as is" without express or implied warranty. *
\r
14 **************************************************************************/
\r
16 ////////////////////////////////////////////////
\r
17 //---------------------------------------------
\r
18 // Class used to do analysis on conversion pairs
\r
19 //---------------------------------------------
\r
20 ////////////////////////////////////////////////
\r
22 // --- ROOT system ---
\r
25 //---- ANALYSIS system ----
\r
26 #include "AliV0Reader.h"
\r
27 #include "AliAnalysisManager.h"
\r
28 #include "AliESDInputHandler.h"
\r
29 #include "AliESDtrack.h"
\r
30 #include "AliMCEvent.h"
\r
31 #include "AliKFVertex.h"
\r
33 #include "AliStack.h"
\r
34 #include "AliMCEventHandler.h"
\r
41 using namespace std;
\r
43 ClassImp(AliV0Reader)
\r
47 AliV0Reader::AliV0Reader() :
\r
55 fCurrentV0IndexNumber(0),
\r
57 fCurrentNegativeKFParticle(NULL),
\r
58 fCurrentPositiveKFParticle(NULL),
\r
59 fCurrentMotherKFCandidate(NULL),
\r
60 fCurrentNegativeESDTrack(NULL),
\r
61 fCurrentPositiveESDTrack(NULL),
\r
62 fNegativeTrackLorentzVector(NULL),
\r
63 fPositiveTrackLorentzVector(NULL),
\r
64 fMotherCandidateLorentzVector(NULL),
\r
68 fPositiveTrackPID(0),
\r
69 fNegativeTrackPID(0),
\r
70 fNegativeMCParticle(NULL),
\r
71 fPositiveMCParticle(NULL),
\r
72 fMotherMCParticle(NULL),
\r
73 fMotherCandidateKFMass(0),
\r
74 fMotherCandidateKFWidth(0),
\r
75 fUseKFParticle(kTRUE),
\r
76 fUseESDTrack(kFALSE),
\r
78 fMaxR(10000),// 100 meter(outside of ALICE)
\r
81 fLineCutZRSlope(0.),
\r
83 fChi2CutConversion(0.),
\r
85 fPIDProbabilityCutNegativeParticle(0),
\r
86 fPIDProbabilityCutPositiveParticle(0),
\r
91 fUseImprovedVertex(kFALSE),
\r
92 fCurrentEventGoodV0s(),
\r
93 fPreviousEventGoodV0s()
\r
99 AliV0Reader::AliV0Reader(const AliV0Reader & original) :
\r
101 fMCStack(original.fMCStack),
\r
102 fMCTruth(original.fMCTruth),
\r
103 fChain(original.fChain),
\r
104 fESDHandler(original.fESDHandler),
\r
105 fESDEvent(original.fESDEvent),
\r
106 fHistograms(original.fHistograms),
\r
107 fCurrentV0IndexNumber(original.fCurrentV0IndexNumber),
\r
108 fCurrentV0(original.fCurrentV0),
\r
109 fCurrentNegativeKFParticle(original.fCurrentNegativeKFParticle),
\r
110 fCurrentPositiveKFParticle(original.fCurrentPositiveKFParticle),
\r
111 fCurrentMotherKFCandidate(original.fCurrentMotherKFCandidate),
\r
112 fCurrentNegativeESDTrack(original.fCurrentNegativeESDTrack),
\r
113 fCurrentPositiveESDTrack(original.fCurrentPositiveESDTrack),
\r
114 fNegativeTrackLorentzVector(original.fNegativeTrackLorentzVector),
\r
115 fPositiveTrackLorentzVector(original.fPositiveTrackLorentzVector),
\r
116 fMotherCandidateLorentzVector(original.fMotherCandidateLorentzVector),
\r
117 fCurrentXValue(original.fCurrentXValue),
\r
118 fCurrentYValue(original.fCurrentYValue),
\r
119 fCurrentZValue(original.fCurrentZValue),
\r
120 fPositiveTrackPID(original.fPositiveTrackPID),
\r
121 fNegativeTrackPID(original.fNegativeTrackPID),
\r
122 fNegativeMCParticle(original.fNegativeMCParticle),
\r
123 fPositiveMCParticle(original.fPositiveMCParticle),
\r
124 fMotherMCParticle(original.fMotherMCParticle),
\r
125 fMotherCandidateKFMass(original.fMotherCandidateKFMass),
\r
126 fMotherCandidateKFWidth(original.fMotherCandidateKFWidth),
\r
127 fUseKFParticle(kTRUE),
\r
128 fUseESDTrack(kFALSE),
\r
130 fMaxR(original.fMaxR),
\r
131 fEtaCut(original.fEtaCut),
\r
132 fPtCut(original.fPtCut),
\r
133 fLineCutZRSlope(original.fLineCutZRSlope),
\r
134 fLineCutZValue(original.fLineCutZValue),
\r
135 fChi2CutConversion(original.fChi2CutConversion),
\r
136 fChi2CutMeson(original.fChi2CutMeson),
\r
137 fPIDProbabilityCutNegativeParticle(original.fPIDProbabilityCutNegativeParticle),
\r
138 fPIDProbabilityCutPositiveParticle(original.fPIDProbabilityCutPositiveParticle),
\r
139 fXVertexCut(original.fXVertexCut),
\r
140 fYVertexCut(original.fYVertexCut),
\r
141 fZVertexCut(original.fZVertexCut),
\r
142 fNSigmaMass(original.fNSigmaMass),
\r
143 fUseImprovedVertex(original.fUseImprovedVertex),
\r
144 fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),
\r
145 fPreviousEventGoodV0s(original.fPreviousEventGoodV0s)
\r
151 AliV0Reader & AliV0Reader::operator = (const AliV0Reader & /*source*/)
\r
153 // assignment operator
\r
157 void AliV0Reader::Initialize(){
\r
158 //see header file for documentation
\r
160 // Get the input handler from the manager
\r
161 fESDHandler = (AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
\r
162 if(fESDHandler == NULL){
\r
163 //print warning here
\r
166 // Get pointer to esd event from input handler
\r
167 fESDEvent = fESDHandler->GetEvent();
\r
168 if(fESDEvent == NULL){
\r
169 //print warning here
\r
172 //Get pointer to MCTruth
\r
173 fMCTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
\r
174 if(fMCTruth == NULL){
\r
175 //print warning here
\r
178 //Get pointer to the mc stack
\r
179 fMCStack = fMCTruth->MCEvent()->Stack();
\r
180 if(fMCStack == NULL){
\r
181 //print warning here
\r
184 AliKFParticle::SetField(fESDEvent->GetMagneticField());
\r
188 AliESDv0* AliV0Reader::GetV0(Int_t index){
\r
189 //see header file for documentation
\r
191 fCurrentV0 = fESDEvent->GetV0(index);
\r
192 UpdateV0Information();
\r
196 Bool_t AliV0Reader::CheckForPrimaryVertex(){
\r
197 return fESDEvent->GetPrimaryVertex()->GetNContributors()>0;
\r
202 Bool_t AliV0Reader::NextV0(){
\r
203 //see header file for documentation
\r
205 Bool_t iResult=kFALSE;
\r
206 while(fCurrentV0IndexNumber<fESDEvent->GetNumberOfV0s()){
\r
207 fCurrentV0 = fESDEvent->GetV0(fCurrentV0IndexNumber);
\r
209 //checks if on the fly mode is set
\r
210 if ( !fCurrentV0->GetOnFlyStatus() ){
\r
211 if(fHistograms != NULL){
\r
212 fHistograms->FillHistogram("ESD_CutGetOnFly_InvMass",GetMotherCandidateMass());
\r
214 fCurrentV0IndexNumber++;
\r
218 //checks if we have a prim vertex
\r
219 if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {
\r
220 if(fHistograms != NULL){
\r
221 fHistograms->FillHistogram("ESD_CutNContributors_InvMass",GetMotherCandidateMass());
\r
223 fCurrentV0IndexNumber++;
\r
227 //Check the pid probability
\r
228 if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){
\r
229 if(fHistograms != NULL){
\r
230 fHistograms->FillHistogram("ESD_CutPIDProb_InvMass",GetMotherCandidateMass());
\r
232 fCurrentV0IndexNumber++;
\r
237 fCurrentV0->GetXYZ(fCurrentXValue,fCurrentYValue,fCurrentZValue);
\r
240 if(GetXYRadius()>fMaxR){ // cuts on distance from collision point
\r
241 if(fHistograms != NULL){
\r
242 fHistograms->FillHistogram("ESD_CutR_InvMass",GetMotherCandidateMass());
\r
244 fCurrentV0IndexNumber++;
\r
249 if((TMath::Abs(fCurrentZValue)*fLineCutZRSlope)-fLineCutZValue > GetXYRadius() ){ // cuts out regions where we do not reconstruct
\r
250 if(fHistograms != NULL){
\r
251 fHistograms->FillHistogram("ESD_CutLine_InvMass",GetMotherCandidateMass());
\r
253 fCurrentV0IndexNumber++;
\r
258 if(UpdateV0Information() == kFALSE){
\r
259 fCurrentV0IndexNumber++;
\r
263 if(fUseKFParticle){
\r
264 if(fCurrentMotherKFCandidate->GetNDF()<=0){
\r
265 if(fHistograms != NULL){
\r
266 fHistograms->FillHistogram("ESD_CutNDF_InvMass",GetMotherCandidateMass());
\r
268 fCurrentV0IndexNumber++;
\r
273 Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();
\r
274 if(chi2V0 > fChi2CutConversion || chi2V0 <=0){
\r
275 if(fHistograms != NULL){
\r
276 fHistograms->FillHistogram("ESD_CutChi2_InvMass",GetMotherCandidateMass());
\r
278 fCurrentV0IndexNumber++;
\r
283 if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){
\r
284 if(fHistograms != NULL){
\r
285 fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());
\r
287 fCurrentV0IndexNumber++;
\r
292 if(fMotherCandidateLorentzVector->Pt()<fPtCut){
\r
293 if(fHistograms != NULL){
\r
294 fHistograms->FillHistogram("ESD_CutPt_InvMass",GetMotherCandidateMass());
\r
296 fCurrentV0IndexNumber++;
\r
302 else if(fUseESDTrack){
\r
306 fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);
\r
308 iResult=kTRUE;//means we have a v0 who survived all the cuts applied
\r
310 fCurrentV0IndexNumber++;
\r
317 Bool_t AliV0Reader::UpdateV0Information(){
\r
318 //see header file for documentation
\r
320 Bool_t iResult=kTRUE; // for taking out not refitted, kinks and like sign tracks
\r
322 Bool_t switchTracks = kFALSE;
\r
324 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
\r
325 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
\r
327 if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){ // avoid like sign
\r
329 if(fHistograms != NULL){
\r
330 fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
\r
334 if(fCurrentPositiveESDTrack->GetSign() == -1 && fCurrentNegativeESDTrack->GetSign() == 1){ // switch wrong signed tracks
\r
335 fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
\r
336 fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
\r
337 switchTracks = kTRUE;
\r
340 if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ||
\r
341 !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){
\r
342 // if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) ||
\r
343 // !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){
\r
346 if(fHistograms != NULL){
\r
347 fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
\r
352 if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 ||
\r
353 fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {
\r
356 if(fHistograms != NULL){
\r
357 fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
\r
363 if(fCurrentNegativeKFParticle != NULL){
\r
364 delete fCurrentNegativeKFParticle;
\r
366 if(switchTracks == kFALSE){
\r
367 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fNegativeTrackPID);
\r
370 fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fNegativeTrackPID);
\r
373 if(fCurrentPositiveKFParticle != NULL){
\r
374 delete fCurrentPositiveKFParticle;
\r
376 if(switchTracks == kFALSE){
\r
377 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fPositiveTrackPID);
\r
380 fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fPositiveTrackPID);
\r
383 if(fCurrentMotherKFCandidate != NULL){
\r
384 delete fCurrentMotherKFCandidate;
\r
386 fCurrentMotherKFCandidate = new AliKFParticle(*fCurrentNegativeKFParticle,*fCurrentPositiveKFParticle);
\r
389 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
\r
390 fCurrentMotherKFCandidate->SetMassConstraint(0,fNSigmaMass);
\r
396 if(fUseImprovedVertex == kTRUE){
\r
397 AliKFVertex primaryVertexImproved(*GetPrimaryVertex());
\r
398 primaryVertexImproved+=*fCurrentMotherKFCandidate;
\r
399 fCurrentMotherKFCandidate->SetProductionVertex(primaryVertexImproved);
\r
402 fCurrentMotherKFCandidate->GetMass(fMotherCandidateKFMass,fMotherCandidateKFWidth);
\r
405 if(fNegativeTrackLorentzVector != NULL){
\r
406 delete fNegativeTrackLorentzVector;
\r
408 if(fUseKFParticle){
\r
409 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeKFParticle->Px(),fCurrentNegativeKFParticle->Py(),fCurrentNegativeKFParticle->Pz());
\r
411 else if(fUseESDTrack){
\r
412 fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeESDTrack->Px(),fCurrentNegativeESDTrack->Py(),fCurrentNegativeESDTrack->Pz());
\r
415 if(fPositiveTrackLorentzVector != NULL){
\r
416 delete fPositiveTrackLorentzVector;
\r
418 if(fUseKFParticle){
\r
419 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveKFParticle->Px(),fCurrentPositiveKFParticle->Py(),fCurrentPositiveKFParticle->Pz());
\r
421 else if(fUseESDTrack){
\r
422 fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveESDTrack->Px(),fCurrentPositiveESDTrack->Py(),fCurrentPositiveESDTrack->Pz());
\r
425 if(fMotherCandidateLorentzVector != NULL){
\r
426 delete fMotherCandidateLorentzVector;
\r
428 if(fUseKFParticle){
\r
429 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
\r
431 else if(fUseESDTrack){
\r
432 fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);
\r
435 if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){
\r
436 fMotherCandidateLorentzVector->SetXYZM(fMotherCandidateLorentzVector->Px() ,fMotherCandidateLorentzVector->Py(),fMotherCandidateLorentzVector->Pz(),0.);
\r
440 if(fDoMC == kTRUE){
\r
441 fMotherMCParticle= NULL;
\r
442 fNegativeMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));
\r
443 fPositiveMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetPindex())->GetLabel()));
\r
444 if(fPositiveMCParticle->GetMother(0)>-1){
\r
445 fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));
\r
449 // if(iResult==kTRUE){
\r
450 // fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate); // moved it to NextV0() after all the cuts are applied
\r
458 Bool_t AliV0Reader::HasSameMCMother(){
\r
459 //see header file for documentation
\r
461 Bool_t iResult = kFALSE;
\r
462 if(fDoMC == kTRUE){
\r
463 if(fNegativeMCParticle != NULL && fPositiveMCParticle != NULL){
\r
464 if(fNegativeMCParticle->GetMother(0) == fPositiveMCParticle->GetMother(0))
\r
465 if(fMotherMCParticle){
\r
473 Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut){
\r
474 //see header file for documentation
\r
476 Bool_t iResult=kFALSE;
\r
478 Double_t *posProbArray = new Double_t[10];
\r
479 Double_t *negProbArray = new Double_t[10];
\r
480 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
\r
481 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
\r
483 negTrack->GetTPCpid(negProbArray);
\r
484 posTrack->GetTPCpid(posProbArray);
\r
486 if(negProbArray!=NULL && posProbArray!=NULL){
\r
487 if(negProbArray[GetSpeciesIndex(-1)]>=negProbCut && posProbArray[GetSpeciesIndex(1)]>=posProbCut){
\r
491 delete [] posProbArray;
\r
492 delete [] negProbArray;
\r
496 void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){
\r
498 Double_t *posProbArray = new Double_t[10];
\r
499 Double_t *negProbArray = new Double_t[10];
\r
500 AliESDtrack* negTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());
\r
501 AliESDtrack* posTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());
\r
503 negTrack->GetTPCpid(negProbArray);
\r
504 posTrack->GetTPCpid(posProbArray);
\r
506 if(negProbArray!=NULL && posProbArray!=NULL){
\r
507 negPIDProb = negProbArray[GetSpeciesIndex(-1)];
\r
508 posPIDProb = posProbArray[GetSpeciesIndex(1)];
\r
510 delete [] posProbArray;
\r
511 delete [] negProbArray;
\r
514 void AliV0Reader::UpdateEventByEventData(){
\r
515 //see header file for documentation
\r
517 if(fCurrentEventGoodV0s.size() >0 ){
\r
518 // fPreviousEventGoodV0s.clear();
\r
519 // fPreviousEventGoodV0s = fCurrentEventGoodV0s;
\r
520 if(fPreviousEventGoodV0s.size()>19){
\r
521 for(UInt_t nCurrent=0;nCurrent<fCurrentEventGoodV0s.size();nCurrent++){
\r
522 fPreviousEventGoodV0s.erase(fPreviousEventGoodV0s.begin());
\r
523 fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));
\r
527 for(UInt_t nCurrent=0;nCurrent<fCurrentEventGoodV0s.size();nCurrent++){
\r
528 if(fPreviousEventGoodV0s.size()<20){
\r
529 fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));
\r
532 fPreviousEventGoodV0s.erase(fPreviousEventGoodV0s.begin());
\r
533 fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));
\r
538 fCurrentEventGoodV0s.clear();
\r
540 fCurrentV0IndexNumber=0;
\r
544 Double_t AliV0Reader::GetNegativeTrackPhi() const{
\r
545 //see header file for documentation
\r
548 if(fNegativeTrackLorentzVector->Phi()> TMath::Pi()){
\r
549 offset = -2*TMath::Pi();
\r
551 return fNegativeTrackLorentzVector->Phi()+offset;
\r
554 Double_t AliV0Reader::GetPositiveTrackPhi() const{
\r
555 //see header file for documentation
\r
558 if(fPositiveTrackLorentzVector->Phi()> TMath::Pi()){
\r
559 offset = -2*TMath::Pi();
\r
561 return fPositiveTrackLorentzVector->Phi()+offset;
\r
564 Double_t AliV0Reader::GetMotherCandidatePhi() const{
\r
565 //see header file for documentation
\r
568 if(fMotherCandidateLorentzVector->Phi()> TMath::Pi()){
\r
569 offset = -2*TMath::Pi();
\r
571 return fMotherCandidateLorentzVector->Phi()+offset;
\r
575 Double_t AliV0Reader::GetMotherCandidateRapidity() const{
\r
576 //see header file for documentation
\r
578 Double_t rapidity=0;
\r
579 if(fMotherCandidateLorentzVector->Energy() - fMotherCandidateLorentzVector->Pz() == 0 || fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz() == 0) rapidity=0;
\r
580 else rapidity = 0.5*(TMath::Log((fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz()) / (fMotherCandidateLorentzVector->Energy()-fMotherCandidateLorentzVector->Pz())));
\r
589 Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
\r
590 //see header file for documentation
\r
592 Int_t iResult = 10; // Unknown particle
\r
594 if(chargeOfTrack==-1){ //negative track
\r
595 switch(abs(fNegativeTrackPID)){
\r
596 case 11: //electron
\r
608 case 2212: //proton
\r
617 case 2112: //neutron
\r
624 //Put in here for kSPECIES::kEleCon ????
\r
627 else if(chargeOfTrack==1){ //positive track
\r
628 switch(abs(fPositiveTrackPID)){
\r
629 case 11: //electron
\r
641 case 2212: //proton
\r
650 case 2112: //neutron
\r
657 //Put in here for kSPECIES::kEleCon ????
\r
661 //Wrong parameter.. Print warning
\r