]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODTracklets.cxx
TPCNoiseMapComponent included into build (Kelly)
[u/mrichter/AliRoot.git] / STEER / 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 "AliAODTracklets.h"
25
26 ClassImp(AliAODTracklets)
27
28 AliAODTracklets::AliAODTracklets() : TNamed(), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0), fLabelsL2(0)
29 {
30   // default constructor
31 }
32
33 AliAODTracklets::AliAODTracklets(const char* name, const char* title) : TNamed(name, title), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0), fLabelsL2(0)
34 {
35   // TNamed constructor
36 }
37
38 AliAODTracklets::AliAODTracklets(const AliAODTracklets& tracklet) :
39     TNamed(tracklet),
40     fNTracks(tracklet.fNTracks),
41     fTheta(0),
42     fPhi(0),
43     fDeltaPhi(0),
44     fLabels(0), 
45     fLabelsL2(0)
46 {
47 // Copy constructor
48     fTheta = new Double32_t[fNTracks];
49     fPhi = new Double32_t[fNTracks];
50     fDeltaPhi = new Double32_t[fNTracks];
51     fLabels = new Int_t[fNTracks];
52     fLabelsL2 = new Int_t[fNTracks];
53     for (Int_t i = 0; i < fNTracks; i++) {
54         fTheta[i]    = tracklet.fTheta[i];
55         fPhi[i]      = tracklet.fPhi[i];
56         fDeltaPhi[i] = tracklet.fDeltaPhi[i];
57         fLabels[i]   = tracklet.fLabels[i];
58         fLabelsL2[i]   = tracklet.fLabelsL2[i];
59     }
60 }
61
62 AliAODTracklets& AliAODTracklets::operator=(const AliAODTracklets& tracklet)
63 {
64 // Assignment operator
65     if(&tracklet == this) return *this;
66     TNamed::operator=(tracklet);
67     fNTracks = tracklet.fNTracks;
68     for (Int_t i = 0; i < fNTracks; i++) {
69         fTheta[i]    = tracklet.fTheta[i];
70         fPhi[i]      = tracklet.fPhi[i];
71         fDeltaPhi[i] = tracklet.fDeltaPhi[i];
72         fLabels[i]   = tracklet.fLabels[i];
73         fLabelsL2[i]   = tracklet.fLabelsL2[i];
74     }
75     return *this;
76 }
77
78 void AliAODTracklets::CreateContainer(Int_t nTracks)
79 {
80   // function that creates container to store tracklets
81
82   DeleteContainer();
83   
84   fNTracks = nTracks;
85
86   if (fNTracks <= 0) {
87     fNTracks = 0;
88     return;
89   }
90
91   fTheta = new Double32_t[fNTracks];
92   fPhi = new Double32_t[fNTracks];
93   fDeltaPhi = new Double32_t[fNTracks];
94   fLabels = new Int_t[fNTracks];
95   fLabelsL2 = new Int_t[fNTracks];
96 }
97
98
99 AliAODTracklets::~AliAODTracklets()
100 {
101   // destructor
102
103   DeleteContainer();
104 }
105
106 void AliAODTracklets::DeleteContainer()
107 {
108   // deletes allocated memory
109
110   if (fTheta)
111   {
112     delete[] fTheta;
113     fTheta = 0;
114   }
115
116   if (fPhi)
117   {
118     delete[] fPhi;
119     fPhi = 0;
120   }
121
122   if (fDeltaPhi)
123   {
124     delete[] fDeltaPhi;
125     fDeltaPhi = 0;
126   }
127
128   if (fLabels)
129   {
130     delete[] fLabels;
131     fLabels = 0;
132   }
133
134   if (fLabelsL2)
135   {
136     delete[] fLabelsL2;
137     fLabelsL2 = 0;
138   }
139
140   fNTracks = 0;
141 }
142
143 Bool_t AliAODTracklets::SetTracklet(Int_t pos, Double32_t theta, Double32_t phi, Double32_t deltaPhi, Int_t labelL1, Int_t labelL2)
144 {
145   // Sets a tracklet at the given position
146
147   if (pos < 0 || pos >= fNTracks)
148     return kFALSE;
149
150   fTheta[pos] = theta;
151   fPhi[pos] = phi;
152   fDeltaPhi[pos] = deltaPhi;
153   fLabels[pos] = labelL1;
154   fLabelsL2[pos] = labelL2;
155
156   return kTRUE;
157 }
158