]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPIDDefESD.cxx
Made a general review to fix as possible most coding conventions violations.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPIDDefESD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 //-------------------------------------------------------------------------
17 //                      Class AliRsnPIDDefESD
18 //                     -------------------
19 //           Simple collection of reconstructed tracks
20 //           selected from an ESD event
21 //           to be used for analysis.
22 //           .........................................
23 //
24 // author: A. Pulvirenti             (email: alberto.pulvirenti@ct.infn.it)
25 //-------------------------------------------------------------------------
26
27 #include <TString.h>
28
29 #include "AliLog.h"
30 #include "AliESDtrack.h"
31 #include "AliRsnPIDDefESD.h"
32
33 ClassImp(AliRsnPIDDefESD)
34
35 //_____________________________________________________________________________
36 AliRsnPIDDefESD::AliRsnPIDDefESD() :
37     fUseESDWeights(kTRUE)
38 {
39 //
40 // Default constructor.
41 // By default, it is set for using ESD weights,
42 // so, values in other members are meaningless.
43 //
44
45   Int_t i;
46   for (i = 0; i < kDetectors; i++) {
47     fUseDet[i] = kTRUE;
48     fDivValue[i] = 0.0;
49     fUseHigher[i] = kTRUE;
50   }
51 }
52
53 //_____________________________________________________________________________
54 AliRsnPIDDefESD::AliRsnPIDDefESD(const AliRsnPIDDefESD& copy) :
55     TObject(copy),
56     fUseESDWeights(copy.fUseESDWeights)
57 {
58 //
59 // Copy constructor.
60 // Implemented to manage passing of this object to functions
61 //
62
63   Int_t i;
64   for (i = 0; i < kDetectors; i++) {
65     fUseDet[i] = copy.fUseDet[i];
66     fDivValue[i] = copy.fDivValue[i];
67     fUseHigher[i] = copy.fUseHigher[i];
68   }
69 }
70
71 //_____________________________________________________________________________
72 void AliRsnPIDDefESD::SetScheme(EScheme scheme, Double_t divValue)
73 {
74 //
75 // Set one of the predefined schemes
76 //
77
78   switch (scheme) {
79   case kSchemeESD:
80     fUseESDWeights = kTRUE;
81     break;
82   case kSchemeITS:
83     fUseESDWeights = kFALSE;
84     ExcludeAll();
85     IncludeDet(kITS);
86     SetDivValue(kITS, 0.0);
87     break;
88   case kSchemeTPC:
89     fUseESDWeights = kFALSE;
90     ExcludeAll();
91     IncludeDet(kTPC);
92     SetDivValue(kTPC, 0.0);
93     break;
94   case kSchemeTOF:
95     fUseESDWeights = kFALSE;
96     ExcludeAll();
97     IncludeDet(kTOF);
98     SetDivValue(kTOF, 0.0);
99     break;
100   case kSchemeITSandTPC:
101     fUseESDWeights = kFALSE;
102     ExcludeAll();
103     IncludeDet(kITS);
104     IncludeDet(kTPC);
105     SetDivValue(kITS, 0.0);
106     SetDivValue(kTPC, 0.0);
107     break;
108   case kSchemeITSandTOF:
109     fUseESDWeights = kFALSE;
110     ExcludeAll();
111     IncludeDet(kITS);
112     IncludeDet(kTOF);
113     SetDivValue(kITS, 0.0);
114     SetDivValue(kTOF, 0.0);
115     break;
116   case kSchemeTPCandTOF:
117     fUseESDWeights = kFALSE;
118     ExcludeAll();
119     IncludeDet(kTPC);
120     IncludeDet(kTOF);
121     SetDivValue(kTPC, 0.0);
122     SetDivValue(kTOF, 0.0);
123     break;
124   case kSchemeITSandTPCandTOF:
125     fUseESDWeights = kFALSE;
126     ExcludeAll();
127     IncludeDet(kITS);
128     IncludeDet(kTPC);
129     IncludeDet(kTOF);
130     SetDivValue(kITS, 0.0);
131     SetDivValue(kTPC, 0.0);
132     SetDivValue(kTOF, 0.0);
133     break;
134   case kSchemeITSandTPCandTOFwithSP:
135     fUseESDWeights = kFALSE;
136     ExcludeAll();
137     IncludeDet(kITS);
138     IncludeDet(kTPC);
139     IncludeDet(kTOF);
140     SetDivValue(kITS, 0.0);
141     SetDivValue(kTPC, 0.0);
142     SetDivValue(kTOF, divValue);
143     break;
144   case kSchemeITSandTPCorTOFwithSP:
145     fUseESDWeights = kFALSE;
146     ExcludeAll();
147     IncludeDet(kITS);
148     IncludeDet(kTPC);
149     IncludeDet(kTOF);
150     SetDivValue(kITS, divValue, kFALSE);
151     SetDivValue(kTPC, divValue, kFALSE);
152     SetDivValue(kTOF, divValue, kTRUE);
153     break;
154   default:
155     AliWarning("PID scheme unrecognized. Set to ESD");
156     fUseESDWeights = kTRUE;
157   }
158 }
159
160 //_____________________________________________________________________________
161 void AliRsnPIDDefESD::ComputeWeights(AliESDtrack *track, Double_t *weights)
162 {
163 //
164 // Computes the global PID weights using the given ranges
165 //
166
167   if (fUseESDWeights) {
168     track->GetESDpid(weights);
169     return;
170   }
171
172   Double_t pt = track->Pt();
173   Double_t w[kDetectors][AliPID::kSPECIES];
174   track->GetITSpid(w[kITS]);
175   track->GetTPCpid(w[kTPC]);
176   track->GetTRDpid(w[kTRD]);
177   track->GetTOFpid(w[kTOF]);
178   track->GetHMPIDpid(w[kHMPID]);
179
180   Int_t i, j;
181   for (i = 0; i < kDetectors; i++) {
182 //     if (!fUseDet[i] || pt < fDivValue[i])
183     if (!fUseDet[i] || !CheckDivValue((EDetector)i,pt)) {
184       for (j = 0; j < AliPID::kSPECIES; j++) {
185         w[i][j] = 1.0;
186       }
187     }
188   }
189
190   for (i = 0; i < AliPID::kSPECIES; i++) {
191     weights[i] = w[kITS][i] * w[kTPC][i] * w[kTRD][i] * w[kTOF][i] * w[kHMPID][i];
192   }
193 }
194
195 //_____________________________________________________________________________
196 void AliRsnPIDDefESD::PrintStatus()
197 {
198 //
199 // Print informations about this object configurations
200 //
201
202   AliInfo("===== PIDDef status messages -- BEGIN");
203
204   if (fUseESDWeights) {
205     AliInfo("Using ESD weights");
206   } else {
207     AliInfo("NOT using ESD weights");
208   }
209
210   Int_t i;
211   for (i = 0; i < kDetectors; i++) {
212     AliInfo(Form("Detector name: %s -- accepted: %s -- divValue = %3.1f useHigher = %s", DetName((EDetector)i), (fUseDet[i]?"YES":"NO"), fDivValue[i],(fUseHigher[i]?"YES":"NO")));
213   }
214
215   AliInfo("===== PIDDef status messages -- END");
216 }
217
218 //_____________________________________________________________________________
219 const char* AliRsnPIDDefESD::DetName(EDetector det) const
220 {
221 //
222 // Detector name for messages
223 //
224
225   switch (det) {
226   case kITS: return "ITS";
227   case kTPC: return "TPC";
228   case kTRD: return "TRD";
229   case kTOF: return "TOF";
230   case kHMPID: return "HMPID";
231   default: return "undef";
232   }
233 }
234
235 //_____________________________________________________________________________
236 const char* AliRsnPIDDefESD::SchemeName()
237 {
238 //
239 // Scheme name for messages
240 //
241
242   TString out;
243
244   Int_t i, ndet = 0;
245
246   for (i = 0; i < kDetectors; i++)
247     if (fUseDet[i]) {
248       if (ndet > 0) out += '_';
249       out.Append(DetName((EDetector)i));
250     }
251
252   return out.Data();
253 }
254
255 //_____________________________________________________________________________
256 void AliRsnPIDDefESD::SetDivValue(EDetector det, Double_t value, Bool_t userHigher)
257 {
258 //
259 // Sets div.value properties for detector
260 //
261   if (CheckBounds(det)) {
262     fDivValue[det] = value;
263     fUseHigher[det] = userHigher;
264   }
265 }
266
267 //_____________________________________________________________________________
268 Bool_t AliRsnPIDDefESD::CheckDivValue(EDetector det,Double_t value)
269 {
270 //
271 // Sets div.value properties for detector
272 //
273   if (CheckBounds(det)) {
274     if (fUseHigher[det]) {
275       if (value > fDivValue[det]) return kTRUE;
276       else return kFALSE;
277     } else {
278       if (value < fDivValue[det]) return kTRUE;
279       else return kFALSE;
280     }
281   }
282
283   return kTRUE;
284 }