]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODCluster.cxx
Adding a protection in the case of DAQ FXS failure
[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   AliVParticle(),
30   fEnergy(0),
31   fChi2(-999.),
32   fID(-999),
33   fLabel(-999),
34   fType(kUndef),
35   fCovMatrix(NULL),
36   fProdVertex(0x0),
37   fPrimTrack(NULL)
38 {
39   // default constructor
40
41   SetPosition((Float_t*)NULL);
42   SetPID((Float_t*)NULL);
43 }
44
45 //______________________________________________________________________________
46 AliAODCluster::AliAODCluster(Int_t id,
47                              Int_t label, 
48                              Double_t energy,
49                              Double_t x[3],
50                              Double_t covMatrix[10],
51                              Double_t pid[9],
52                              AliAODVertex *prodVertex,
53                              AliAODTrack *primTrack,
54                              Char_t ttype) :
55   AliVParticle(),
56   fEnergy(energy),
57   fChi2(-999.),
58   fID(id),
59   fLabel(label),
60   fType(ttype),
61   fCovMatrix(NULL),
62   fProdVertex(prodVertex),
63   fPrimTrack(primTrack)
64 {
65   // constructor
66  
67   SetPosition(x);
68   if(covMatrix) SetCovMatrix(covMatrix);
69   SetPID(pid);
70
71 }
72
73 //______________________________________________________________________________
74 AliAODCluster::AliAODCluster(Int_t id,
75                              Int_t label, 
76                              Float_t energy,
77                              Float_t x[3],
78                              Float_t covMatrix[10],
79                              Float_t pid[9],
80                              AliAODVertex *prodVertex,
81                              AliAODTrack *primTrack,
82                              Char_t ttype) :
83   AliVParticle(),
84   fEnergy(energy),
85   fChi2(-999.),
86   fID(id),
87   fLabel(label),
88   fType(ttype),
89   fCovMatrix(NULL),
90   fProdVertex(prodVertex),
91   fPrimTrack(primTrack)
92 {
93   // constructor
94  
95   SetPosition(x);
96   if(covMatrix) SetCovMatrix(covMatrix);
97   SetPID(pid);
98
99 }
100
101
102 //______________________________________________________________________________
103 AliAODCluster::~AliAODCluster() 
104 {
105   // destructor
106   delete fCovMatrix;
107 }
108
109
110 //______________________________________________________________________________
111 AliAODCluster::AliAODCluster(const AliAODCluster& clus) :
112   AliVParticle(clus),
113   fEnergy(clus.fEnergy),
114   fChi2(clus.fChi2),
115   fID(clus.fID),
116   fLabel(clus.fLabel),
117   fType(clus.fType),
118   fCovMatrix(NULL),
119   fProdVertex(clus.fProdVertex),
120   fPrimTrack(clus.fPrimTrack)
121 {
122   // Copy constructor
123
124   clus.GetPosition(fPosition);
125   if(clus.fCovMatrix) fCovMatrix=new AliAODRedCov<4>(*clus.fCovMatrix);
126   SetPID(clus.fPID);
127
128 }
129
130 //______________________________________________________________________________
131 AliAODCluster& AliAODCluster::operator=(const AliAODCluster& clus)
132 {
133   // Assignment operator
134   if(this!=&clus) {
135
136     AliVParticle::operator=(clus);
137
138     clus.GetPosition(fPosition);
139     clus.GetPID(fPID);
140
141     fEnergy = clus.fEnergy;
142     fChi2 = clus.fChi2;
143
144     fID = clus.fID;
145     fLabel = clus.fLabel;    
146
147     fType = clus.fType;
148     
149     delete fCovMatrix;
150     if(clus.fCovMatrix) fCovMatrix=new AliAODRedCov<4>(*clus.fCovMatrix);
151     else fCovMatrix=NULL;
152
153     fProdVertex = clus.fProdVertex;
154     fPrimTrack = clus.fPrimTrack;
155   }
156
157   return *this;
158 }
159
160 //______________________________________________________________________________
161 template <class T> void AliAODCluster::SetPosition(const T *x) 
162 {
163   // set the position
164
165   if (x) {
166       fPosition[0] = x[0];
167       fPosition[1] = x[1];
168       fPosition[2] = x[2];
169   } else {
170
171     fPosition[0] = -999.;
172     fPosition[1] = -999.;
173     fPosition[2] = -999.;
174   }
175 }
176
177 //______________________________________________________________________________
178 AliAODCluster::AODCluPID_t AliAODCluster::GetMostProbablePID() const 
179 {
180   // Returns the most probable PID array element.
181   
182   Int_t nPID = 9;
183   if (fPID) {
184     AODCluPID_t loc = kUnknown;
185     Double_t max = 0.;
186     Bool_t allTheSame = kTRUE;
187     
188     for (Int_t iPID = 0; iPID < nPID; iPID++) {
189       if (fPID[iPID] >= max) {
190         if (fPID[iPID] > max) {
191           allTheSame = kFALSE;
192           max = fPID[iPID];
193           loc = (AODCluPID_t)iPID;
194         } else {
195           allTheSame = kTRUE;
196         }
197       }
198     }
199     
200     return allTheSame ? kUnknown : loc;
201   } else {
202     return kUnknown;
203   }
204 }
205
206 //______________________________________________________________________________
207 void AliAODCluster::Print(Option_t* /* option */) const
208 {
209   // prints information about AliAODCluster
210
211   printf("Object name: %s   Cluster type: %s\n", GetName(), GetTitle()); 
212   printf("    energy = %f\n", E());
213   printf("      chi2 = %f\n", Chi2());
214   printf(" PID object: %p\n", PID());
215 }
216