]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/AliHFEV0taginfo.cxx
change in handling of V0 tagged tracks
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEV0taginfo.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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  * 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  **************************************************************************/
15 //
16 // Class AliHFEV0taginfo
17 // Creates list of tracks with V0 information
18 //
19 // Author:
20 //   Jan Wagner <J.Wagner@gsi.de>
21 //
22
23
24
25
26 #include <iostream>
27 #include <TClass.h>
28 #include <TList.h>
29 #include <TMath.h>
30
31
32 #include "AliLog.h"
33 #include "AliESDEvent.h"
34 #include "AliESDv0.h"
35
36 #include "AliHFEV0taginfo.h"
37
38
39 ClassImp(AliHFEV0taginfo)
40 ClassImp(AliHFEV0taginfo::AliHFEV0tag)
41
42 //___________________________________________________________________
43 AliHFEV0taginfo::AliHFEV0taginfo():
44     TNamed(), 
45     fTaggedTracks(NULL),
46     fV0finder(NULL)
47 {
48     //
49     // default constructor
50     //
51 }
52 //___________________________________________________________________
53 AliHFEV0taginfo::AliHFEV0taginfo(const char* name):
54     TNamed(name, ""), 
55     fTaggedTracks(NULL),
56     fV0finder(NULL)
57 {
58     //
59     // constructor
60     //
61
62     fTaggedTracks = new TList();
63     if(fTaggedTracks){
64         fTaggedTracks->SetOwner();
65     }
66     fV0finder = new AliESDv0KineCuts();
67 }
68 //___________________________________________________________________
69 AliHFEV0taginfo::~AliHFEV0taginfo(){
70
71     //
72     // Destructor
73     //
74     delete fTaggedTracks;
75     delete fV0finder;
76     AliDebug(6, "DESTRUCTOR");
77 }
78
79 //________________________________________________________________________________
80 // loops over V0s in event and fills fTaggedTracks with V0 tracks
81 void AliHFEV0taginfo::TagV0Tracks(AliESDEvent *fEvent){
82
83     if (!fEvent) return;
84
85     const Int_t nTracks = fEvent->GetNumberOfTracks();
86     if(nTracks < 2) return;
87
88     const Int_t nV0s = fEvent->GetNumberOfV0s();
89     if(nV0s < 1) return;
90     AliDebug(3,Form("%d V0s found!",nV0s));
91
92     fV0finder->SetEvent(fEvent);
93
94     for(Int_t i=0; i<nV0s; ++i){
95         Int_t pdgP = 0;
96         Int_t pdgN = 0;
97         AliESDv0 *fV0 = fEvent->GetV0(i);
98         if(!fV0) continue;
99         if(fV0finder->ProcessV0(fV0,pdgP,pdgN)){
100             AliDebug(5,Form("V0 has: pos pdg: %d, neg pdg: %d",pdgP,pdgN));
101             AddTrack(fV0->GetPindex(),pdgP);
102             AddTrack(fV0->GetNindex(),pdgN);
103         }
104     }
105 }
106
107 //________________________________________________________________________________
108 //Translates the pdg code to AliPID enum and adds track to tagged list
109 void AliHFEV0taginfo::AddTrack(Int_t TrackID, Int_t pdgCode){
110
111     if(TrackID<0) return;
112     AliPID::EParticleType Pinfo;
113     switch (TMath::Abs(pdgCode)){
114         case  11:
115             Pinfo = AliPID::kElectron;
116             break;
117         case  211:
118             Pinfo = AliPID::kPion;
119             break;
120         case  2212:
121             Pinfo = AliPID::kProton;
122             break;
123         default:
124             return;
125     }
126     fTaggedTracks->Add(new AliHFEV0tag(TrackID, Pinfo));
127     AliDebug(4,Form("Added new Track ID: %d with PID: %d, #entry: %d",TrackID, Pinfo, fTaggedTracks->GetEntries()));
128 }
129
130
131 //________________________________________________________________________________
132 //check for V0 information from track ID 
133 //returns AliPID::kUnknown if track ID not found
134 AliPID::EParticleType AliHFEV0taginfo::GetV0Info(Int_t trackID){
135
136     AliHFEV0tag test(trackID, AliPID::kUnknown);
137     AliHFEV0tag *result = dynamic_cast<AliHFEV0tag *>(fTaggedTracks->FindObject(&test));
138     if(!result){ 
139         AliDebug(6, Form("Could not find track ID %d", trackID));
140         return AliPID::kUnknown;
141     }
142     return result->GetPinfo();
143 }
144
145 //________________________________________________________________________________
146 //resets the fTaggedTracks TList
147 void AliHFEV0taginfo::Reset(){
148     fTaggedTracks->Delete();
149 }
150
151
152 //___________________________________________________________________
153 AliHFEV0taginfo::AliHFEV0tag::AliHFEV0tag():
154     TObject(), 
155     fTrackID(0),
156     fPinfo(AliPID::kUnknown)
157 {
158     // default constructor
159 }
160 //___________________________________________________________________
161 AliHFEV0taginfo::AliHFEV0tag::AliHFEV0tag(Int_t TrackID, AliPID::EParticleType Pinfo):
162     TObject(), 
163     fTrackID(TrackID),
164     fPinfo(Pinfo)
165 {
166 }
167
168 //____________________________________________________________
169 AliHFEV0taginfo::AliHFEV0tag::AliHFEV0tag(const AliHFEV0tag &ref):
170     TObject(ref),
171     fTrackID(ref.fTrackID),
172     fPinfo(ref.fPinfo)
173 {
174     // Copy constructor
175 }
176
177 //____________________________________________________________
178 AliHFEV0taginfo::AliHFEV0tag &AliHFEV0taginfo::AliHFEV0tag::operator=(const AliHFEV0tag &ref){
179     // Assignment operator
180     if(this != &ref){
181         TObject::operator=(ref);
182
183         fTrackID = ref.fTrackID;
184         fPinfo = ref.fPinfo;
185     }
186     return *this;
187 }
188
189 //___________________________________________________________________
190 AliHFEV0taginfo::AliHFEV0tag::~AliHFEV0tag(){
191     //
192     // Destructor
193     //
194     AliDebug(6, "DESTRUCTOR");
195 }
196
197 //Set track ID and particle info 
198 //___________________________________________________________________
199 void AliHFEV0taginfo::AliHFEV0tag::SetTrack(const Int_t trackID, const AliPID::EParticleType Pinfo){
200     fTrackID = trackID;
201     fPinfo = Pinfo;
202 }
203 //____________________________________________________________
204 Bool_t AliHFEV0taginfo::AliHFEV0tag::IsEqual(const TObject *ref) const {
205     //
206     // Check for equality  of track ID
207     //
208     const AliHFEV0tag *refObj = dynamic_cast<const AliHFEV0tag *>(ref);
209     if(!refObj) return kFALSE;
210     return (fTrackID == refObj->GetTrackID());
211 }
212 //____________________________________________________________
213 Int_t AliHFEV0taginfo::AliHFEV0tag::Compare(const TObject *ref) const{
214     //
215     // Compares two objects
216     // Order:
217     //   First compare track ID then particle info
218     //
219     const AliHFEV0tag *refObj = dynamic_cast<const AliHFEV0tag *>(ref);
220     if(fTrackID < refObj->GetTrackID()) return -1;
221     else if(fTrackID > refObj->GetTrackID()) return 1;
222     else{
223         if(fPinfo < refObj->GetPinfo()) return -1;
224         else if(fPinfo > refObj->GetPinfo()) return 1;
225         else return 0;
226     }
227 }
228
229