Return value corrected. (Carlos Perez Lara)
[u/mrichter/AliRoot.git] / STEER / AliCentrality.cxx
CommitLineData
d15bf53f 1/**************************************************************************
2 * Copyright(c) 1998-2008, 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//*****************************************************
a540a9d3 17// Class AliCentrality
d15bf53f 18// author: Alberica Toia
19//*****************************************************
fba4b2e2 20/// A container for the centrality stored in AOD in ESD
d15bf53f 21
fba4b2e2 22#include "AliCentrality.h"
d15bf53f 23
fba4b2e2 24ClassImp(AliCentrality)
d15bf53f 25
fba4b2e2 26AliCentrality::AliCentrality() : TNamed("Centrality", "Centrality"),
a540a9d3 27 fQuality(0),
d15bf53f 28 fCentralityV0M(0),
29 fCentralityFMD(0),
30 fCentralityTRK(0),
31 fCentralityTKL(0),
32 fCentralityCL0(0),
be0d4e9b 33 fCentralityCL1(0),
d15bf53f 34 fCentralityV0MvsFMD(0),
35 fCentralityTKLvsV0M(0),
36 fCentralityZEMvsZDC(0)
37{
38 /// constructor
39}
40
fba4b2e2 41AliCentrality::AliCentrality(const AliCentrality& cnt) :
a540a9d3 42 TNamed(cnt),
43 fQuality(cnt.fQuality),
d15bf53f 44 fCentralityV0M(cnt.fCentralityV0M),
45 fCentralityFMD(cnt.fCentralityFMD),
46 fCentralityTRK(cnt.fCentralityTRK),
47 fCentralityTKL(cnt.fCentralityTKL),
48 fCentralityCL0(cnt.fCentralityCL0),
be0d4e9b 49 fCentralityCL1(cnt.fCentralityCL1),
d15bf53f 50 fCentralityV0MvsFMD(cnt.fCentralityV0MvsFMD),
51 fCentralityTKLvsV0M(cnt.fCentralityTKLvsV0M),
52 fCentralityZEMvsZDC(cnt.fCentralityZEMvsZDC)
53{
54 /// Copy constructor
55}
56
fba4b2e2 57AliCentrality& AliCentrality::operator=(const AliCentrality& c)
d15bf53f 58{
59 /// Assignment operator
60 if (this!=&c) {
61 TNamed::operator=(c);
a540a9d3 62 fQuality = c.fQuality;
d15bf53f 63 fCentralityV0M = c.fCentralityV0M;
64 fCentralityFMD = c.fCentralityFMD;
65 fCentralityTRK = c.fCentralityTRK;
66 fCentralityTKL = c.fCentralityTKL;
67 fCentralityCL0 = c.fCentralityCL0;
be0d4e9b 68 fCentralityCL1 = c.fCentralityCL1;
d15bf53f 69 fCentralityV0MvsFMD = c.fCentralityV0MvsFMD;
70 fCentralityTKLvsV0M = c.fCentralityTKLvsV0M;
71 fCentralityZEMvsZDC = c.fCentralityZEMvsZDC;
72 }
73
74 return *this;
75}
76
fba4b2e2 77AliCentrality::~AliCentrality()
d15bf53f 78{
79 /// destructor
80}
81
a540a9d3 82Int_t AliCentrality::GetQuality()
83{
84 return fQuality;
85}
86
fba4b2e2 87Float_t AliCentrality::GetCentralityPercentile(const char *x)
a540a9d3 88{
89 if (fQuality == 0) {
90 TString method = x;
91 if(method.CompareTo("V0M")==0) return fCentralityV0M;
92 if(method.CompareTo("FMD")==0) return fCentralityFMD;
93 if(method.CompareTo("TRK")==0) return fCentralityTRK;
94 if(method.CompareTo("TKL")==0) return fCentralityTKL;
95 if(method.CompareTo("CL0")==0) return fCentralityCL0;
96 if(method.CompareTo("CL1")==0) return fCentralityCL1;
97 if(method.CompareTo("V0MvsFMD")==0) return fCentralityV0MvsFMD;
98 if(method.CompareTo("TKLvsV0M")==0) return fCentralityTKLvsV0M;
99 if(method.CompareTo("ZENvsZDC")==0) return fCentralityZEMvsZDC;
100 return -1;
101 } else {
102 return -1;
103 }
104}
105
106Int_t AliCentrality::GetCentralityClass10(const char *x)
107{
108 if (fQuality == 0) {
109 TString method = x;
110 if(method.CompareTo("V0M")==0) return (Int_t) (fCentralityV0M / 10.0);
111 if(method.CompareTo("FMD")==0) return (Int_t) (fCentralityFMD / 10.0);
112 if(method.CompareTo("TRK")==0) return (Int_t) (fCentralityTRK / 10.0);
113 if(method.CompareTo("TKL")==0) return (Int_t) (fCentralityTKL / 10.0);
114 if(method.CompareTo("CL0")==0) return (Int_t) (fCentralityCL0 / 10.0);
115 if(method.CompareTo("CL1")==0) return (Int_t) (fCentralityCL1 / 10.0);
116 if(method.CompareTo("V0MvsFMD")==0) return (Int_t) (fCentralityV0MvsFMD / 10.0);
117 if(method.CompareTo("TKLvsV0M")==0) return (Int_t) (fCentralityTKLvsV0M / 10.0);
118 if(method.CompareTo("ZENvsZDC")==0) return (Int_t) (fCentralityZEMvsZDC / 10.0);
119 return -1;
120 } else {
121 return -1;
122 }
123}
124
125Int_t AliCentrality::GetCentralityClass5(const char *x)
126{
127 if (fQuality == 0) {
128 TString method = x;
129 if(method.CompareTo("V0M")==0) return (Int_t) (fCentralityV0M / 5.0);
130 if(method.CompareTo("FMD")==0) return (Int_t) (fCentralityFMD / 5.0);
131 if(method.CompareTo("TRK")==0) return (Int_t) (fCentralityTRK / 5.0);
132 if(method.CompareTo("TKL")==0) return (Int_t) (fCentralityTKL / 5.0);
133 if(method.CompareTo("CL0")==0) return (Int_t) (fCentralityCL0 / 5.0);
134 if(method.CompareTo("CL1")==0) return (Int_t) (fCentralityCL1 / 5.0);
135 if(method.CompareTo("V0MvsFMD")==0) return (Int_t) (fCentralityV0MvsFMD / 5.0);
136 if(method.CompareTo("TKLvsV0M")==0) return (Int_t) (fCentralityTKLvsV0M / 5.0);
137 if(method.CompareTo("ZENvsZDC")==0) return (Int_t) (fCentralityZEMvsZDC / 5.0);
138 return -1;
139 } else {
140 return -1;
141 }
142}
143
144
145Bool_t AliCentrality::IsEventInCentralityClass(Float_t a, Float_t b, const char *x)
146{
147 if (fQuality == 0) {
148 TString method = x;
149 if ((method.CompareTo("V0M")==0) && (fCentralityV0M >=a && fCentralityV0M < b)) return kTRUE;
150 if ((method.CompareTo("FMD")==0) && (fCentralityFMD >=a && fCentralityFMD < b)) return kTRUE;
151 if ((method.CompareTo("TRK")==0) && (fCentralityTRK >=a && fCentralityTRK < b)) return kTRUE;
152 if ((method.CompareTo("TKL")==0) && (fCentralityTKL >=a && fCentralityTKL < b)) return kTRUE;
153 if ((method.CompareTo("CL0")==0) && (fCentralityCL0 >=a && fCentralityCL0 < b)) return kTRUE;
154 if ((method.CompareTo("CL1")==0) && (fCentralityCL1 >=a && fCentralityCL1 < b)) return kTRUE;
155 if ((method.CompareTo("V0MvsFMD")==0) && (fCentralityV0MvsFMD >=a && fCentralityV0MvsFMD < b)) return kTRUE;
156 if ((method.CompareTo("TKLvsV0M")==0) && (fCentralityTKLvsV0M >=a && fCentralityTKLvsV0M < b)) return kTRUE;
157 if ((method.CompareTo("ZEMvsZDC")==0) && (fCentralityZEMvsZDC >=a && fCentralityZEMvsZDC < b)) return kTRUE;
158 else return kFALSE;
159 } else {
067ce65d 160 return kFALSE;
a540a9d3 161 }
162}
163
164Float_t AliCentrality::GetCentralityPercentileUnchecked(const char *x)
d15bf53f 165{
166 TString method = x;
167 if(method.CompareTo("V0M")==0) return fCentralityV0M;
168 if(method.CompareTo("FMD")==0) return fCentralityFMD;
169 if(method.CompareTo("TRK")==0) return fCentralityTRK;
170 if(method.CompareTo("TKL")==0) return fCentralityTKL;
171 if(method.CompareTo("CL0")==0) return fCentralityCL0;
be0d4e9b 172 if(method.CompareTo("CL1")==0) return fCentralityCL1;
d15bf53f 173 if(method.CompareTo("V0MvsFMD")==0) return fCentralityV0MvsFMD;
174 if(method.CompareTo("TKLvsV0M")==0) return fCentralityTKLvsV0M;
175 if(method.CompareTo("ZENvsZDC")==0) return fCentralityZEMvsZDC;
176 return -1;
177}
178
a540a9d3 179Int_t AliCentrality::GetCentralityClass10Unchecked(const char *x)
d15bf53f 180{
181 TString method = x;
182 if(method.CompareTo("V0M")==0) return (Int_t) (fCentralityV0M / 10.0);
183 if(method.CompareTo("FMD")==0) return (Int_t) (fCentralityFMD / 10.0);
184 if(method.CompareTo("TRK")==0) return (Int_t) (fCentralityTRK / 10.0);
185 if(method.CompareTo("TKL")==0) return (Int_t) (fCentralityTKL / 10.0);
186 if(method.CompareTo("CL0")==0) return (Int_t) (fCentralityCL0 / 10.0);
be0d4e9b 187 if(method.CompareTo("CL1")==0) return (Int_t) (fCentralityCL1 / 10.0);
d15bf53f 188 if(method.CompareTo("V0MvsFMD")==0) return (Int_t) (fCentralityV0MvsFMD / 10.0);
189 if(method.CompareTo("TKLvsV0M")==0) return (Int_t) (fCentralityTKLvsV0M / 10.0);
190 if(method.CompareTo("ZENvsZDC")==0) return (Int_t) (fCentralityZEMvsZDC / 10.0);
191 return -1;
192}
193
a540a9d3 194Int_t AliCentrality::GetCentralityClass5Unchecked(const char *x)
d15bf53f 195{
a540a9d3 196 TString method = x;
d15bf53f 197 if(method.CompareTo("V0M")==0) return (Int_t) (fCentralityV0M / 5.0);
198 if(method.CompareTo("FMD")==0) return (Int_t) (fCentralityFMD / 5.0);
199 if(method.CompareTo("TRK")==0) return (Int_t) (fCentralityTRK / 5.0);
200 if(method.CompareTo("TKL")==0) return (Int_t) (fCentralityTKL / 5.0);
201 if(method.CompareTo("CL0")==0) return (Int_t) (fCentralityCL0 / 5.0);
be0d4e9b 202 if(method.CompareTo("CL1")==0) return (Int_t) (fCentralityCL1 / 5.0);
d15bf53f 203 if(method.CompareTo("V0MvsFMD")==0) return (Int_t) (fCentralityV0MvsFMD / 5.0);
204 if(method.CompareTo("TKLvsV0M")==0) return (Int_t) (fCentralityTKLvsV0M / 5.0);
205 if(method.CompareTo("ZENvsZDC")==0) return (Int_t) (fCentralityZEMvsZDC / 5.0);
206 return -1;
a540a9d3 207}
d15bf53f 208
a540a9d3 209Bool_t AliCentrality::IsEventInCentralityClassUnchecked(Float_t a, Float_t b, const char *x)
d15bf53f 210{
211 TString method = x;
212 if ((method.CompareTo("V0M")==0) && (fCentralityV0M >=a && fCentralityV0M < b)) return kTRUE;
213 if ((method.CompareTo("FMD")==0) && (fCentralityFMD >=a && fCentralityFMD < b)) return kTRUE;
214 if ((method.CompareTo("TRK")==0) && (fCentralityTRK >=a && fCentralityTRK < b)) return kTRUE;
215 if ((method.CompareTo("TKL")==0) && (fCentralityTKL >=a && fCentralityTKL < b)) return kTRUE;
216 if ((method.CompareTo("CL0")==0) && (fCentralityCL0 >=a && fCentralityCL0 < b)) return kTRUE;
be0d4e9b 217 if ((method.CompareTo("CL1")==0) && (fCentralityCL1 >=a && fCentralityCL1 < b)) return kTRUE;
d15bf53f 218 if ((method.CompareTo("V0MvsFMD")==0) && (fCentralityV0MvsFMD >=a && fCentralityV0MvsFMD < b)) return kTRUE;
219 if ((method.CompareTo("TKLvsV0M")==0) && (fCentralityTKLvsV0M >=a && fCentralityTKLvsV0M < b)) return kTRUE;
220 if ((method.CompareTo("ZEMvsZDC")==0) && (fCentralityZEMvsZDC >=a && fCentralityZEMvsZDC < b)) return kTRUE;
221 else return kFALSE;
a540a9d3 222}
d15bf53f 223
224