- Three classes by MinJung Kweon AliHFEpriVtx, AliHFEsecVtx and AliHFEmcQA for primar...
[u/mrichter/AliRoot.git] / STEER / AliAODCluster.cxx
CommitLineData
df9db588 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//-------------------------------------------------------------------------
a9255000 19// AOD cluster base class
df9db588 20// Author: Markus Oldenburg, CERN
21//-------------------------------------------------------------------------
22
a9255000 23#include "AliAODCluster.h"
df9db588 24
a9255000 25ClassImp(AliAODCluster)
df9db588 26
27//______________________________________________________________________________
a9255000 28AliAODCluster::AliAODCluster() :
df9db588 29 fEnergy(0),
30 fChi2(-999.),
31 fID(-999),
4cfedff1 32 fNLabel(0),
33 fLabel(0x0),
34 fFilterMap(0),
35 fType(kUndef)
df9db588 36{
37 // default constructor
38
39 SetPosition((Float_t*)NULL);
40 SetPID((Float_t*)NULL);
41}
42
43//______________________________________________________________________________
a9255000 44AliAODCluster::AliAODCluster(Int_t id,
4cfedff1 45 UInt_t nLabel,
46 Int_t *label,
df9db588 47 Double_t energy,
48 Double_t x[3],
83dd7da3 49 Double_t pid[13],
4cfedff1 50 Char_t ttype,
51 UInt_t selectInfo) :
df9db588 52 fEnergy(energy),
53 fChi2(-999.),
54 fID(id),
4cfedff1 55 fNLabel(0),
56 fLabel(0x0),
57 fFilterMap(selectInfo),
58 fType(ttype)
df9db588 59{
60 // constructor
61
01afc3fc 62 SetPosition(x);
df9db588 63 SetPID(pid);
4cfedff1 64 SetLabel(label, nLabel);
df9db588 65}
66
67//______________________________________________________________________________
a9255000 68AliAODCluster::AliAODCluster(Int_t id,
4cfedff1 69 UInt_t nLabel,
70 Int_t *label,
df9db588 71 Float_t energy,
72 Float_t x[3],
83dd7da3 73 Float_t pid[13],
4cfedff1 74 Char_t ttype,
75 UInt_t selectInfo) :
df9db588 76 fEnergy(energy),
77 fChi2(-999.),
78 fID(id),
4cfedff1 79 fNLabel(0),
80 fLabel(0x0),
81 fFilterMap(selectInfo),
82 fType(ttype)
df9db588 83{
84 // constructor
85
01afc3fc 86 SetPosition(x);
df9db588 87 SetPID(pid);
4cfedff1 88 SetLabel(label, nLabel);
df9db588 89}
90
91
92//______________________________________________________________________________
a9255000 93AliAODCluster::~AliAODCluster()
df9db588 94{
95 // destructor
4cfedff1 96
97 RemoveLabel();
df9db588 98}
99
100
101//______________________________________________________________________________
14d55e62 102AliAODCluster::AliAODCluster(const AliAODCluster& clus) :
4cfedff1 103 TObject(clus),
14d55e62 104 fEnergy(clus.fEnergy),
105 fChi2(clus.fChi2),
106 fID(clus.fID),
4cfedff1 107 fNLabel(0),
108 fLabel(0x0),
109 fFilterMap(clus.fFilterMap),
110 fType(clus.fType)
df9db588 111{
112 // Copy constructor
113
14d55e62 114 clus.GetPosition(fPosition);
14d55e62 115 SetPID(clus.fPID);
4cfedff1 116 SetLabel(clus.fLabel, clus.fNLabel);
df9db588 117}
118
119//______________________________________________________________________________
14d55e62 120AliAODCluster& AliAODCluster::operator=(const AliAODCluster& clus)
df9db588 121{
122 // Assignment operator
14d55e62 123 if(this!=&clus) {
df9db588 124
14d55e62 125 clus.GetPosition(fPosition);
126 clus.GetPID(fPID);
df9db588 127
14d55e62 128 fEnergy = clus.fEnergy;
129 fChi2 = clus.fChi2;
df9db588 130
14d55e62 131 fID = clus.fID;
4cfedff1 132 SetLabel(clus.fLabel, clus.fNLabel);
133 fFilterMap = clus.fFilterMap;
9333290e 134
135 fType = clus.fType;
df9db588 136 }
137
138 return *this;
139}
140
141//______________________________________________________________________________
a9255000 142template <class T> void AliAODCluster::SetPosition(const T *x)
df9db588 143{
144 // set the position
145
146 if (x) {
df9db588 147 fPosition[0] = x[0];
148 fPosition[1] = x[1];
149 fPosition[2] = x[2];
df9db588 150 } else {
df9db588 151
152 fPosition[0] = -999.;
153 fPosition[1] = -999.;
154 fPosition[2] = -999.;
155 }
156}
157
158//______________________________________________________________________________
14d55e62 159AliAODCluster::AODCluPID_t AliAODCluster::GetMostProbablePID() const
160{
161 // Returns the most probable PID array element.
162
83dd7da3 163 Int_t nPID = 13;
14d55e62 164 if (fPID) {
165 AODCluPID_t loc = kUnknown;
166 Double_t max = 0.;
167 Bool_t allTheSame = kTRUE;
168
169 for (Int_t iPID = 0; iPID < nPID; iPID++) {
170 if (fPID[iPID] >= max) {
171 if (fPID[iPID] > max) {
172 allTheSame = kFALSE;
173 max = fPID[iPID];
174 loc = (AODCluPID_t)iPID;
175 } else {
176 allTheSame = kTRUE;
177 }
178 }
179 }
180
181 return allTheSame ? kUnknown : loc;
182 } else {
183 return kUnknown;
184 }
185}
186
187//______________________________________________________________________________
4cfedff1 188void AliAODCluster::SetLabel(Int_t *label, UInt_t size)
189{
190 if (label && size>0) {
191 if (size != (UInt_t)fNLabel) {
192 RemoveLabel();
193 fNLabel = size;
194 fLabel = new Int_t[fNLabel];
195 }
196
197 for (Int_t i = 0; i < fNLabel; i++) {
198 fLabel[i] = label[i];
199 }
200 } else {
201 RemoveLabel();
202 }
203
204 return;
205}
206
207//______________________________________________________________________________
208Int_t AliAODCluster::GetLabel(UInt_t i) const
209{
210 if (fLabel && i < (UInt_t)fNLabel) {
211 return fLabel[i];
212 } else {
213 return -999;
214 }
215}
216
217//______________________________________________________________________________
218void AliAODCluster::RemoveLabel()
219{
220 delete[] fLabel;
221 fLabel = 0x0;
222 fNLabel = 0;
223
224 return;
225}
226
227//______________________________________________________________________________
a9255000 228void AliAODCluster::Print(Option_t* /* option */) const
df9db588 229{
a9255000 230 // prints information about AliAODCluster
df9db588 231
4cfedff1 232 printf("Cluster type: %d\n", GetType());
233 printf(" energy = %f\n", E());
234 printf(" chi2 = %f\n", Chi2());
f12d42ce 235 printf(" PID object: %p\n", static_cast<const void*>(PID()));
df9db588 236}