]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODTracklets.cxx
Fix on the setter of VZEROEqFactors
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODTracklets.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 //     AOD class to store tracklets
20 //     Author: Jan Fiete Grosse-Oetringhaus, CERN
21 //     Class created from AliMultiplicity
22 //-------------------------------------------------------------------------
23
24 #include <TString.h>
25 #include "AliAODTracklets.h"
26
27 ClassImp(AliAODTracklets)
28
29 AliAODTracklets::AliAODTracklets() : AliVMultiplicity(), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0), fLabelsL2(0)
30 {
31   // default constructor
32 }
33
34 AliAODTracklets::AliAODTracklets(const char* name, const char* title) : AliVMultiplicity(name, title), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0), fLabelsL2(0)
35 {
36   // Named constructor
37 }
38
39 AliAODTracklets::AliAODTracklets(const AliAODTracklets& tracklet) :
40     AliVMultiplicity(tracklet),
41     fNTracks(tracklet.fNTracks),
42     fTheta(0),
43     fPhi(0),
44     fDeltaPhi(0),
45     fLabels(0), 
46     fLabelsL2(0)
47 {
48 // Copy constructor
49     fTheta = new Double32_t[fNTracks];
50     fPhi = new Double32_t[fNTracks];
51     fDeltaPhi = new Double32_t[fNTracks];
52     fLabels = new Int_t[fNTracks];
53     fLabelsL2 = new Int_t[fNTracks];
54     for (Int_t i = 0; i < fNTracks; i++) {
55         fTheta[i]    = tracklet.fTheta[i];
56         fPhi[i]      = tracklet.fPhi[i];
57         fDeltaPhi[i] = tracklet.fDeltaPhi[i];
58         fLabels[i]   = tracklet.fLabels[i];
59         fLabelsL2[i]   = tracklet.fLabelsL2[i];
60     }
61 }
62
63 AliAODTracklets& AliAODTracklets::operator=(const AliAODTracklets& tracklet)
64 {
65 // Assignment operator
66     if(&tracklet == this) return *this;
67     AliVMultiplicity::operator=(tracklet);
68     if(fNTracks!=tracklet.fNTracks){
69       fNTracks = tracklet.fNTracks;
70       CreateContainer(fNTracks);
71     }
72     for (Int_t i = 0; i < fNTracks; i++) {
73         fTheta[i]    = tracklet.fTheta[i];
74         fPhi[i]      = tracklet.fPhi[i];
75         fDeltaPhi[i] = tracklet.fDeltaPhi[i];
76         fLabels[i]   = tracklet.fLabels[i];
77         fLabelsL2[i]   = tracklet.fLabelsL2[i];
78     }
79     return *this;
80 }
81
82 void AliAODTracklets::CreateContainer(Int_t nTracks)
83 {
84   // function that creates container to store tracklets
85
86   DeleteContainer();
87   
88   fNTracks = nTracks;
89
90   if (fNTracks <= 0) {
91     fNTracks = 0;
92     return;
93   }
94
95   fTheta = new Double32_t[fNTracks];
96   fPhi = new Double32_t[fNTracks];
97   fDeltaPhi = new Double32_t[fNTracks];
98   fLabels = new Int_t[fNTracks];
99   fLabelsL2 = new Int_t[fNTracks];
100 }
101
102
103 AliAODTracklets::~AliAODTracklets()
104 {
105   // destructor
106
107   DeleteContainer();
108 }
109
110 void AliAODTracklets::DeleteContainer()
111 {
112   // deletes allocated memory
113   if (fTheta)
114   {
115     delete[] fTheta;
116     fTheta = 0;
117   }
118
119   if (fPhi)
120   {
121     delete[] fPhi;
122     fPhi = 0;
123   }
124
125   if (fDeltaPhi)
126   {
127     delete[] fDeltaPhi;
128     fDeltaPhi = 0;
129   }
130
131   if (fLabels)
132   {
133     delete[] fLabels;
134     fLabels = 0;
135   }
136
137   if (fLabelsL2)
138   {
139     delete[] fLabelsL2;
140     fLabelsL2 = 0;
141   }
142
143   fNTracks = 0;
144 }
145
146 Bool_t AliAODTracklets::SetTracklet(Int_t pos, Double32_t theta, Double32_t phi, Double32_t deltaPhi, Int_t labelL1, Int_t labelL2)
147 {
148   // Sets a tracklet at the given position
149
150   if (pos < 0 || pos >= fNTracks)
151     return kFALSE;
152
153   fTheta[pos] = theta;
154   fPhi[pos] = phi;
155   fDeltaPhi[pos] = deltaPhi;
156   fLabels[pos] = labelL1;
157   fLabelsL2[pos] = labelL2;
158
159   return kTRUE;
160 }
161
162 //______________________________________________________________________
163 void AliAODTracklets::Print(Option_t *opt) const
164 {
165   // print
166   printf("N.tracklets: %4d | ScaleDThtSin2T:%s\n",fNTracks,GetScaleDThetaBySin2T() ? "ON":"OFF");
167   TString opts = opt; opts.ToLower();
168   //
169   if (opts.Contains("t")) {
170     for (int i=0;i<fNTracks;i++) {
171       printf("T#%3d| Eta:%+5.2f Th:%+6.3f Phi:%+6.3f DPhi:%+6.3f L1:%5d L2:%5d\n",
172              i,GetEta(i),fTheta[i],fPhi[i],fDeltaPhi[i],fLabels[i],fLabelsL2[i]);
173     }
174   }
175   //
176 }
177
178 //________________________________________________________________
179 void AliAODTracklets::SetLabel(Int_t i, Int_t layer,Int_t label)  
180 {
181   // set labels
182   if (i>=0 && i<fNTracks) 
183   {
184     if(layer == 0) fLabels[i] = label;
185     else fLabelsL2[i] = label;
186   }
187 }
188
189 //________________________________________________________________
190 Int_t AliAODTracklets::GetLabel(Int_t i, Int_t layer) const 
191 {
192   // access labels
193   if (i>=0 && i<fNTracks) 
194   {
195     return (layer == 0) ? fLabels[i] : fLabelsL2[i];
196   }
197   else 
198     Error("GetLabel","Invalid track number %d",i); return -9999;
199 }
200
201 //________________________________________________________________
202 Double_t AliAODTracklets::GetTheta(Int_t i) const 
203
204   // access theta's
205   if (i>=0 && i<fNTracks) 
206   {
207     return fTheta[i];
208   }
209   else 
210     Error("GetTheta","Invalid track number %d",i); return -9999.;
211 }
212
213 //________________________________________________________________
214 Double_t AliAODTracklets::GetPhi(Int_t i) const 
215
216   // access phi's
217   if (i>=0 && i<fNTracks) 
218   {
219     return fPhi[i];
220   }
221   else 
222     Error("GetPhi","Invalid track number %d",i); return -9999.;
223 }
224
225 //________________________________________________________________
226 Double_t AliAODTracklets::GetDeltaPhi(Int_t i) const 
227 {
228   // access delta phi's
229   if (i>=0 && i<fNTracks) 
230   {
231     return fDeltaPhi[i];
232   }
233   else 
234     Error("GetDeltaPhi","Invalid track number %d",i); return -9999.;
235 }