Coverity fixes (A. Shabetai)
[u/mrichter/AliRoot.git] / JETAN / DEV / AliJetFillCalTrkTrack.cxx
CommitLineData
d89b8229 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/* $Id$ */
17
18//--------------------------------------------------
19// Filling of CalTrkTrack objects in the reader task
20//
21// Author: magali.estienne@subatech.in2p3.fr
22// alexandre.shabetai@cern.ch
23//-------------------------------------------------
24
25// --- AliRoot header files ---
26#include "AliJetFillCalTrkTrack.h"
27#include "AliJetReaderHeader.h"
28#include "AliVEvent.h"
29#include "AliESDtrack.h"
30#include "AliAODTrack.h"
31
32ClassImp(AliJetFillCalTrkTrack)
33
34/////////////////////////////////////////////////////////////////////
35
36AliJetFillCalTrkTrack::AliJetFillCalTrkTrack():
37 AliJetFillCalTrkEvent(),
38 fHadCorr(0),
39 fApplyMIPCorrection(kTRUE),
40 fVEvt(0x0)
41{
42 // constructor
43}
44
45//-----------------------------------------------------------------------
46AliJetFillCalTrkTrack::AliJetFillCalTrkTrack(AliVEvent* evt):
47 AliJetFillCalTrkEvent(),
48 fHadCorr(0),
49 fApplyMIPCorrection(kTRUE),
50 fVEvt(evt)
51{
52 // constructor
53}
54
55//-----------------------------------------------------------------------
56AliJetFillCalTrkTrack::AliJetFillCalTrkTrack(const AliJetFillCalTrkTrack &det):
57 AliJetFillCalTrkEvent(det),
58 fHadCorr(det.fHadCorr),
59 fApplyMIPCorrection(det.fApplyMIPCorrection),
60 fVEvt(det.fVEvt)
61{
62 // Copy constructor
63}
64
65//-----------------------------------------------------------------------
66AliJetFillCalTrkTrack& AliJetFillCalTrkTrack::operator=(const AliJetFillCalTrkTrack& other)
67{
68 // Assignment
69 if (this != &other) {
70 fHadCorr = other.fHadCorr;
71 fApplyMIPCorrection = other.fApplyMIPCorrection;
72 fVEvt = other.fVEvt;
73 }
74
75 return (*this);
76
77}
78
79//-----------------------------------------------------------------------
80AliJetFillCalTrkTrack::~AliJetFillCalTrkTrack()
81{
82 // destructor
83}
84
85//-----------------------------------------------------------------------
86void AliJetFillCalTrkTrack::Exec(Option_t* const /*option*/)
87{
88 // Main method.
89 // Fill AliJetFillCalTrkTrack the with the charged particle information
90
91 fDebug = fReaderHeader->GetDebug();
92 fOpt = fReaderHeader->GetDetector();
93 TString datatype = fReaderHeader->GetDataType();
94 datatype.ToUpper();
95
96 Int_t type=0;
97
98 if (datatype.Contains("AODEXTRAONLY")) { type=kTrackAODextraonly;}
99 else if (datatype.Contains("AODEXTRA")) { type=kTrackAODextra; }
100 else if (datatype.Contains("AOD")) { type=kTrackAOD; }
101 else if (datatype.Contains("ESD")) { type=kTrackESD; }
102 else { cout<< "Unknown Data type !" << endl; }
103
104 // temporary storage of signal and pt cut flag
105 Bool_t sflag = 0;
106 Bool_t cflag = 0;
107
108 // get cuts set by user
109 Float_t ptMin = fReaderHeader->GetPtCut();
110 Float_t etaMin = fReaderHeader->GetFiducialEtaMin();
111 Float_t etaMax = fReaderHeader->GetFiducialEtaMax();
112 Float_t phiMin = fReaderHeader->GetFiducialPhiMin();
113 Float_t phiMax = fReaderHeader->GetFiducialPhiMax();
114 UInt_t filterMask = ((AliJetReaderHeader*)fReaderHeader)->GetTestFilterMask();
115 UInt_t filterType = ((AliJetReaderHeader*)fReaderHeader)->GetFilterType();
116
117 if(fDebug>2)Printf("%s:%d Selecting tracks with %d",(char*)__FILE__,__LINE__,type);
118
119 Int_t goodTrackStd = 0;
120 Int_t goodTrackNonStd = 0;
121 if(type==kTrackESD || type==kTrackAOD || type==kTrackAODextra || type==kTrackAODextraonly){
122 if(type!=kTrackAODextraonly) {
123 if(!fVEvt){
124 if(fDebug>2)Printf("%s:%d No AOD or ESD input event",(char*)__FILE__,__LINE__);
125 return;
126 }
127 for(int it = 0;it < fVEvt->GetNumberOfTracks();++it){
128 AliVTrack *tr = (AliVTrack*)fVEvt->GetTrack(it);
129 cflag=sflag=0;
130 if(fVEvt->InheritsFrom("AliESDEvent")){
131 // ESD case ....
132 if(tr->GetStatus()==0){
133 if(fDebug>10)Printf("%s:%d Not matching status %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
134 continue;
135 }
136 if ((tr->GetStatus() & AliESDtrack::kTPCrefit) == 0) continue; // quality check
137 if ((tr->GetStatus() & AliESDtrack::kITSrefit) == 0) continue; // quality check
138 if (((AliJetReaderHeader*) fReaderHeader)->ReadSignalOnly()
139 && TMath::Abs(tr->GetLabel()) > 10000) continue; // quality check
140 if (((AliJetReaderHeader*) fReaderHeader)->ReadBkgdOnly()
141 && TMath::Abs(tr->GetLabel()) < 10000) continue; // quality check
142 }
143 if((fVEvt->InheritsFrom("AliAODEvent"))){
144 // AOD case ....
145 AliAODTrack *trAOD = dynamic_cast<AliAODTrack*> (tr);
37f45f89 146 if(!trAOD) continue;
d89b8229 147 Bool_t bGood = false;
148 if(filterType == 0)bGood = true;
149 else if(filterType == 1)bGood = trAOD->IsHybridTPCConstrainedGlobal();
150 else if(filterType == 2)bGood = trAOD->IsHybridGlobalConstrainedGlobal();
151 if((filterMask>0)&&((!trAOD->TestFilterBit(filterMask)||(!bGood)))){
152 if(fDebug>10)Printf("%s:%d Not matching filter %d/%d %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks(),filterMask,trAOD->GetFilterMap());
153 continue;
154 }
155 // Should we also check the GetStatus ?
156 }
157 if((tr->Eta()> etaMax) || (tr->Eta() < etaMin)){
158 if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
159 continue;
160 }
161 Float_t phi = ( (tr->Phi()) < 0) ? (tr->Phi()) + 2. * TMath::Pi() : (tr->Phi());
162 if((phi > phiMax) || (phi < phiMin)){
163 if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
164 continue;
165 }
166 if(tr->Pt() <= ptMin){
167 if(fDebug>10)Printf("%s:%d Not matching pt %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
168 }
169 else {cflag=1;}
170 sflag=(TMath::Abs(tr->GetLabel()) < 10000) ? 1 : 0;
171
172 if(fDebug>10)Printf("%s:%d MATCHED %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
173
174 fCalTrkEvent->AddCalTrkTrack(tr,cflag,sflag);
175 goodTrackStd++;
176 }
177 }
178 if(type==kTrackAODextra || type==kTrackAODextraonly) {
179 if(!fVEvt){
180 return;
181 }
182 TClonesArray *aodExtraTracks = dynamic_cast<TClonesArray*>(fVEvt->FindListObject("aodExtraTracks"));
183 if(!aodExtraTracks) return;
184 for(int it =0; it<aodExtraTracks->GetEntries(); it++) {
185 cflag=sflag=0;
186 AliVParticle *track = dynamic_cast<AliVParticle*> ((*aodExtraTracks)[it]);
187 if (!track) continue;
188 AliAODTrack *trackAOD = dynamic_cast<AliAODTrack*> (track);
189 if(!trackAOD) continue;
190 if (trackAOD->GetStatus() == 0) continue;
191 Bool_t bGood = false;
192 if(filterType == 0)bGood = true;
193 else if(filterType == 1)bGood = trackAOD->IsHybridTPCConstrainedGlobal();
194 else if(filterType == 2)bGood = trackAOD->IsHybridGlobalConstrainedGlobal();
195 if((filterMask>0)&&((!trackAOD->TestFilterBit(filterMask)||(!bGood))))continue;
196 if((trackAOD->Eta()> etaMax) || (trackAOD->Eta() < etaMin)){
197 if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
198 continue;
199 }
200 Float_t phi = ( (trackAOD->Phi()) < 0) ? (trackAOD->Phi()) + 2. * TMath::Pi() : (trackAOD->Phi());
201 if((phi > phiMax) || (phi < phiMin)){
202 if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
203 continue;
204 }
205 if(trackAOD->Pt() <= ptMin){
206 if(fDebug>10)Printf("%s:%d Not matching pt %d/%d",(char*)__FILE__,__LINE__,it,fVEvt->GetNumberOfTracks());
207 }
208 else {cflag=1;}
209 sflag=(TMath::Abs(trackAOD->GetLabel()) < 10000) ? 1 : 0;
210 fCalTrkEvent->AddCalTrkTrack(trackAOD,cflag,sflag);
211 goodTrackNonStd++;
212 }
213 }
214 }
215
216 if(fDebug>0)printf("Number of good tracks selected: %5d \n", goodTrackStd+goodTrackNonStd);
217
218}
219
220
221
222
223
224
225
226
227
228
229
230
231