Coverity fixes (A. Shabetai)
[u/mrichter/AliRoot.git] / JETAN / DEV / AliJetCalTrk.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// CalTrk is used to store Tracks and CaloCells information
20//
21// Author: alexandre.shabetai@cern.ch & magali.estienne@subatech.in2p3.fr
22//-------------------------------------------------
23
24#include "AliJetCalTrk.h"
25
26#include "AliVCaloCells.h"
27
28ClassImp(AliJetCalTrkTrack)
29
30//////////////////////////////////////////////////////////////////
31
32AliJetCalTrkTrack::AliJetCalTrkTrack():
33 TObject(),
34 fCalTrkTrackRef(),
35 fCalTrkCutFlag(kFALSE),
36 fCalTrkSignalFlag(kFALSE),
37 fCalTrkPtCorr(1.)
38{
39 // Default constructor
40}
41
42//------------------------------------------------------------------------
43AliJetCalTrkTrack::AliJetCalTrkTrack(AliVTrack* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr):
44 TObject(),
45 fCalTrkTrackRef(track),
46 fCalTrkCutFlag(cutFlag),
47 fCalTrkSignalFlag(signalFlag),
48 fCalTrkPtCorr(ptCorr)
49{
50 // Constructor 2
51}
52
53//------------------------------------------------------------------------
54AliJetCalTrkTrack::AliJetCalTrkTrack(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr):
55 TObject(),
56 fCalTrkTrackRef(track),
57 fCalTrkCutFlag(cutFlag),
58 fCalTrkSignalFlag(signalFlag),
59 fCalTrkPtCorr(ptCorr)
60{
61 // Constructor 3
62}
63
64//------------------------------------------------------------------------
65AliJetCalTrkTrack::AliJetCalTrkTrack(const AliJetCalTrkTrack& rCalTrk):
66 TObject(rCalTrk),
67 fCalTrkTrackRef(rCalTrk.fCalTrkTrackRef),
68 fCalTrkCutFlag(rCalTrk.fCalTrkCutFlag),
69 fCalTrkSignalFlag(rCalTrk.fCalTrkSignalFlag),
70 fCalTrkPtCorr(rCalTrk.fCalTrkPtCorr)
71{
72 // Copy constructor
73}
74
75//------------------------------------------------------------------------
76AliJetCalTrkTrack& AliJetCalTrkTrack::operator=(const AliJetCalTrkTrack& rhs)
77{
78 // Assignment
79 if (this != &rhs) {
80 TObject::operator=(rhs);
81 fCalTrkTrackRef = rhs.fCalTrkTrackRef;
82 fCalTrkCutFlag = rhs.fCalTrkCutFlag;
83 fCalTrkSignalFlag = rhs.fCalTrkSignalFlag;
84 fCalTrkPtCorr = rhs.fCalTrkPtCorr;
85 }
86 return *this;
87
88}
89
90//------------------------------------------------------------------------
91void AliJetCalTrkTrack::Clear(Option_t* /*option*/)
92{
93 // Clear objects
94 fCalTrkTrackRef = 0;
95 fCalTrkCutFlag = 0;
96 fCalTrkSignalFlag = 0;
97 fCalTrkPtCorr = 1.;
98
99}
100
101//-----------------------------------------------------------------------
102void AliJetCalTrkTrack::Print(const Option_t* option)
103{
104 cout << "Track: " << option << ", Pt: " << GetPt() << ", Eta: " << GetEta() << ", Phi: " << GetPhi() << endl;
37f45f89 105 if (!option) TObject::Print();
d89b8229 106}
107
108//...........................................................................
109//***************************************************************************
110ClassImp(AliJetCalTrkTrackKine)
111
112 AliJetCalTrkTrackKine::AliJetCalTrkTrackKine():
113 AliJetCalTrkTrack(),
114 fCalTrkPtReso(1.),
115 fCalTrkTrackE(-999.),
116 fCalTrkTrackPt(-999.),
117 fCalTrkTrackP(-999.)
118{
119 // Default constructor
120}
121
122//------------------------------------------------------------------------
123AliJetCalTrkTrackKine::AliJetCalTrkTrackKine(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptReso) :
124 AliJetCalTrkTrack(track,cutFlag,signalFlag),
125 fCalTrkPtReso(ptReso),
126 fCalTrkTrackE(-999.),
127 fCalTrkTrackPt(-999.),
128 fCalTrkTrackP(-999.)
129{
130 // Constructor 2
131}
132
133//------------------------------------------------------------------------
134void AliJetCalTrkTrackKine::Clear(Option_t* option)
135{
136 // Clear objects
137 fCalTrkPtReso = 1.;
138 fCalTrkTrackE = -999;
139 fCalTrkTrackPt = -999;
140 fCalTrkTrackP = -999;
141 AliJetCalTrkTrack::Clear(option);
142
143}
144
145//------------------------------------------------------------------------
146Float_t AliJetCalTrkTrackKine::GetE()
147{
148 // Particle energy
149 if(fCalTrkTrackE==-999){
150 if ( fCalTrkPtReso != 1 ){
151 fCalTrkTrackE = TMath::Sqrt(GetPx()*GetPx()+GetPy()*GetPy()+GetPz()*GetPz()+GetM()*GetM());
152 }
153 else {fCalTrkTrackE = GetParticle()->E(); }
154 }
155
156 return fCalTrkTrackE;
157
158}
159
160//------------------------------------------------------------------------
161Float_t AliJetCalTrkTrackKine::GetPt()
162{
163 // Particle transverse momentum
164 if(fCalTrkTrackPt==-999){
165 if ( fCalTrkPtReso != 1 ){
166 fCalTrkTrackPt = TMath::Sqrt(GetPx()*GetPx()+GetPy()*GetPy());
167 }
168 else {fCalTrkTrackPt = GetParticle()->Pt();}
169 }
170
171 return fCalTrkTrackPt;
172
173}
174
175//------------------------------------------------------------------------
176Float_t AliJetCalTrkTrackKine::GetP()
177{
178 // Particle momentum
179 if(fCalTrkTrackP==-999){
180 if ( fCalTrkPtReso != 1 ){
181 fCalTrkTrackP = TMath::Sqrt(GetPx()*GetPx()+GetPy()*GetPy()+GetPz()*GetPz());
182 }
183 else {fCalTrkTrackP = GetParticle()->P(); }
184 }
185
186 return fCalTrkTrackP;
187
188}
189
190//...........................................................................
191//***************************************************************************
192
193ClassImp(AliJetCalTrkEvent)
194
195 AliJetCalTrkEvent::AliJetCalTrkEvent():
196 TObject(),
197 fJetCalTrkTrack(0x0),
198 fJetCalTrkCell(0x0),
199 fNJetCalTrkTrack(0)
200{
201 // Default constructor
202}
203
204//----------------------------------------------------------------
205AliJetCalTrkEvent::AliJetCalTrkEvent(Short_t opt,Bool_t kine,Bool_t kIsHighMult):
206 TObject(),
207 fJetCalTrkTrack(0x0),
208 fJetCalTrkCell(0x0),
209 fNJetCalTrkTrack(0)
210{
211 // Constructor 2
212 if (kine==0) {
213 // Tracks (real or MC)
214 if(opt%2==!0 || opt==0){
215 fJetCalTrkTrack = new TClonesArray("AliJetCalTrkTrack", kIsHighMult*3800+200);
216 }
217 }
218 else { // Kine cases
219 fJetCalTrkTrack = new TClonesArray("AliJetCalTrkTrackKine", kIsHighMult*3800+200);
220 }
221
222}
223
224//----------------------------------------------------------------
225AliJetCalTrkEvent::~AliJetCalTrkEvent()
226{
227 // destructor
228 if (fJetCalTrkTrack) delete fJetCalTrkTrack;
229 if (fJetCalTrkCell) delete fJetCalTrkCell;
230
231}
232//----------------------------------------------------------------
233AliJetCalTrkEvent::AliJetCalTrkEvent(const AliJetCalTrkEvent& rCalTrkEvent):
234 TObject(),
235 fJetCalTrkTrack(rCalTrkEvent.fJetCalTrkTrack),
236 fJetCalTrkCell(rCalTrkEvent.fJetCalTrkCell),
237 fNJetCalTrkTrack(rCalTrkEvent.fNJetCalTrkTrack)
238{
239 // Copy constructor
240}
241
242//----------------------------------------------------------------
243AliJetCalTrkEvent& AliJetCalTrkEvent::operator=(const AliJetCalTrkEvent& rhs)
244{
245 // Assignment
246 if (this != &rhs) {
247 TObject::operator=(rhs);
248 if (fJetCalTrkTrack) delete fJetCalTrkTrack;
249 if (fJetCalTrkCell) delete fJetCalTrkCell;
250 fJetCalTrkTrack = rhs.fJetCalTrkTrack;
251 fJetCalTrkCell = rhs.fJetCalTrkCell;
252 fNJetCalTrkTrack = rhs.fNJetCalTrkTrack;
253 }
254
255 return *this;
256
257}
258
259//----------------------------------------------------------------
260AliJetCalTrkTrack* AliJetCalTrkEvent::AddCalTrkTrack(AliVTrack* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr)
261{
262 // Add a track to the CalTrkEvent
263 TClonesArray &tJetCalTrkTrack = *fJetCalTrkTrack ;
264 AliJetCalTrkTrack *n = new(tJetCalTrkTrack[fNJetCalTrkTrack++]) AliJetCalTrkTrack(track, cutFlag, signalFlag, ptCorr) ;
265 return n ;
266
267}
268
269//----------------------------------------------------------------
270AliJetCalTrkTrack* AliJetCalTrkEvent::AddCalTrkTrack(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptCorr)
271{
272 // Add a track to the CalTrkEvent
273 TClonesArray &tJetCalTrkTrack = *fJetCalTrkTrack ;
274 AliJetCalTrkTrack *n = new(tJetCalTrkTrack[fNJetCalTrkTrack++]) AliJetCalTrkTrack(track, cutFlag, signalFlag, ptCorr) ;
275 return n ;
276
277}
278
279//_________________________________________________________________
280AliJetCalTrkTrackKine* AliJetCalTrkEvent::AddCalTrkTrackKine(AliVParticle* track, Bool_t cutFlag, Bool_t signalFlag, Float_t ptReso)
281{
282 // Add a track to the CalTrkEvent
283 TClonesArray &tJetCalTrkTrack = *fJetCalTrkTrack ;
284 AliJetCalTrkTrackKine *n = new(tJetCalTrkTrack[fNJetCalTrkTrack++]) AliJetCalTrkTrackKine(track, cutFlag, signalFlag, ptReso) ;
285 return n ;
286
287}
288
289
290//----------------------------------------------------------------
291AliJetCalTrkTrack* AliJetCalTrkEvent::GetCalTrkTrack(Int_t i)
292{
293 // Get track i
294 return (AliJetCalTrkTrack*) fJetCalTrkTrack->At(i);
295
296}
297
298//-----------------------------------------------------------------
299void AliJetCalTrkEvent::Clear(Option_t* /*option*/)
300{
301 // Clear object
302
303 if(fJetCalTrkTrack) fJetCalTrkTrack->Clear("C"); // array of Tracks
304 fNJetCalTrkTrack = 0; // Number of tracks
305}
306
307//________________________________________________________________
308void AliJetCalTrkEvent::Print(const Option_t* /*option*/) const
309{
310 // prints event information
311 cout<< "Number of tracks:" << fNJetCalTrkTrack << endl;
312
313}