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