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