]>
Commit | Line | Data |
---|---|---|
db0e2c5f | 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 | // Container class for the reference distributions for TRD PID | |
17 | // The class contains the reference distributions and the momentum steps | |
18 | // the references are taken at. Mapping is done inside. To derive references, | |
19 | // the functions GetUpperReference and GetLowerReference return the next | |
20 | // reference distribution object and the momentum step above respectively below | |
21 | // the tracklet momentum. | |
22 | // | |
23 | // Authors: | |
24 | // Markus Fasel <M.Fasel@gsi.de> | |
25 | // Daniel Lohner <Daniel.Lohner@cern.ch> | |
26 | ||
27 | #include "AliLog.h" | |
28 | ||
29 | #include "AliTRDPIDResponseObject.h" | |
30 | ||
31 | #ifndef AliTRDPIDREFERENCE_H | |
32 | #include "AliTRDPIDReference.h" | |
33 | #endif | |
34 | ||
35 | #ifndef AliTRDPIDPARAMS_H | |
36 | #include "AliTRDPIDParams.h" | |
37 | #endif | |
38 | ||
39 | ||
40 | ClassImp(AliTRDPIDResponseObject) | |
41 | ||
42 | //____________________________________________________________ | |
43 | AliTRDPIDResponseObject::AliTRDPIDResponseObject(): | |
44 | TNamed(), | |
45 | fNSlicesQ0(4) | |
46 | { | |
47 | // | |
48 | // Dummy constructor | |
49 | // | |
50 | SetBit(kIsOwner, kTRUE); | |
51 | ||
52 | for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){ | |
ed8e1dc1 | 53 | fPIDParams[method]=NULL; |
54 | fPIDReference[method]=NULL; | |
db0e2c5f | 55 | } |
56 | } | |
57 | ||
58 | //____________________________________________________________ | |
59 | AliTRDPIDResponseObject::AliTRDPIDResponseObject(const Char_t *name): | |
60 | TNamed(name, "TRD PID Response Object"), | |
61 | fNSlicesQ0(4) | |
62 | { | |
63 | // | |
64 | // Default constructor | |
65 | // | |
66 | SetBit(kIsOwner, kTRUE); | |
67 | ||
68 | for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){ | |
ed8e1dc1 | 69 | fPIDParams[method]=NULL; |
70 | fPIDReference[method]=NULL; | |
db0e2c5f | 71 | } |
72 | } | |
73 | ||
74 | //____________________________________________________________ | |
75 | AliTRDPIDResponseObject::AliTRDPIDResponseObject(const AliTRDPIDResponseObject &ref): | |
76 | TNamed(ref), | |
77 | fNSlicesQ0(ref.fNSlicesQ0) | |
78 | { | |
79 | // | |
80 | // Copy constructor | |
81 | // Only copies pointers, object is not the owner of the references | |
82 | // | |
83 | SetBit(kIsOwner, kFALSE); | |
84 | ||
85 | for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){ | |
ed8e1dc1 | 86 | fPIDParams[method]=ref.fPIDParams[method]; // new Object is not owner, copy only pointer |
87 | fPIDReference[method]=ref.fPIDReference[method]; // new Object is not owner, copy only pointer | |
db0e2c5f | 88 | } |
89 | } | |
90 | //____________________________________________________________ | |
91 | AliTRDPIDResponseObject &AliTRDPIDResponseObject::operator=(const AliTRDPIDResponseObject &ref){ | |
92 | // | |
93 | // Assginment operator | |
94 | // Only copies poiters, object is not the owner of the references | |
95 | // | |
96 | if(this != &ref){ | |
97 | TNamed::operator=(ref); | |
98 | fNSlicesQ0=ref.fNSlicesQ0; | |
99 | for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){ | |
45bbee9a | 100 | if(TestBit(kIsOwner) && fPIDParams[method]){ |
101 | delete fPIDParams[method]; | |
102 | fPIDParams[method]= 0; | |
103 | } | |
104 | if(TestBit(kIsOwner) && fPIDReference[method]){ | |
105 | delete fPIDReference[method]; | |
106 | fPIDReference[method] = 0; | |
107 | } | |
f2762b1c | 108 | printf("Assignment"); |
45bbee9a | 109 | fPIDParams[method]=ref.fPIDParams[method]; // new Object is not owner, copy only pointer |
110 | fPIDReference[method]=ref.fPIDReference[method]; // new Object is not owner, copy only pointer | |
db0e2c5f | 111 | } |
112 | SetBit(kIsOwner, kFALSE); | |
113 | } | |
114 | return *this; | |
115 | } | |
116 | ||
117 | //____________________________________________________________ | |
118 | AliTRDPIDResponseObject::~AliTRDPIDResponseObject(){ | |
119 | // | |
120 | // Destructor | |
121 | // references are deleted if the object is the owner | |
122 | // | |
45bbee9a | 123 | for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){ |
124 | if(fPIDParams && TestBit(kIsOwner)){ | |
125 | delete fPIDParams[method];fPIDParams[method] = 0; | |
126 | } | |
127 | if(fPIDReference && TestBit(kIsOwner)){ | |
128 | delete fPIDReference[method]; | |
129 | fPIDReference[method] = 0; | |
130 | } | |
131 | } | |
db0e2c5f | 132 | } |
133 | ||
134 | //____________________________________________________________ | |
135 | void AliTRDPIDResponseObject::SetPIDParams(AliTRDPIDParams *params,AliTRDPIDResponse::ETRDPIDMethod method){ | |
136 | ||
137 | if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){ | |
138 | AliError("Method does not exist"); | |
139 | return; | |
140 | } | |
ed8e1dc1 | 141 | if(fPIDParams[method]){ |
142 | delete fPIDParams[method]; | |
143 | fPIDParams[method]=NULL; | |
db0e2c5f | 144 | } |
145 | ||
ed8e1dc1 | 146 | fPIDParams[method]=new AliTRDPIDParams(*params); |
db0e2c5f | 147 | } |
148 | ||
149 | //____________________________________________________________ | |
150 | void AliTRDPIDResponseObject::SetPIDReference(AliTRDPIDReference *reference,AliTRDPIDResponse::ETRDPIDMethod method){ | |
151 | ||
152 | if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){ | |
153 | AliError("Method does not exist"); | |
154 | return; | |
155 | } | |
ed8e1dc1 | 156 | if(fPIDReference[method]){ |
157 | delete fPIDReference[method]; | |
158 | fPIDReference[method]=NULL; | |
db0e2c5f | 159 | } |
ed8e1dc1 | 160 | fPIDReference[method]=new AliTRDPIDReference(*reference); |
db0e2c5f | 161 | } |
162 | ||
163 | //____________________________________________________________ | |
164 | TObject *AliTRDPIDResponseObject::GetUpperReference(AliPID::EParticleType spec, Float_t p, Float_t &pUpper,AliTRDPIDResponse::ETRDPIDMethod method) const{ | |
165 | ||
166 | if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){ | |
167 | AliError("Method does not exist"); | |
168 | return NULL; | |
169 | } | |
170 | ||
ed8e1dc1 | 171 | if(fPIDReference[method]){ |
172 | return fPIDReference[method]->GetUpperReference(spec,p,pUpper); | |
db0e2c5f | 173 | } |
174 | return NULL; | |
175 | } | |
176 | ||
177 | ||
178 | //____________________________________________________________ | |
179 | TObject *AliTRDPIDResponseObject::GetLowerReference(AliPID::EParticleType spec, Float_t p, Float_t &pLower,AliTRDPIDResponse::ETRDPIDMethod method) const{ | |
180 | ||
181 | if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){ | |
182 | AliError("Method does not exist"); | |
183 | return NULL; | |
184 | } | |
185 | ||
f2762b1c | 186 | if(fPIDReference[method]){ |
ed8e1dc1 | 187 | return fPIDReference[method]->GetLowerReference(spec,p,pLower); |
db0e2c5f | 188 | } |
189 | return NULL; | |
190 | } | |
191 | ||
192 | //____________________________________________________________ | |
bd58d4b9 | 193 | Bool_t AliTRDPIDResponseObject::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params,Double_t centrality,AliTRDPIDResponse::ETRDPIDMethod method) const{ |
db0e2c5f | 194 | |
195 | if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){ | |
196 | AliError("Method does not exist"); | |
197 | return kFALSE; | |
198 | } | |
199 | ||
ed8e1dc1 | 200 | if(fPIDParams[method]){ |
bd58d4b9 | 201 | return fPIDParams[method]->GetThresholdParameters(ntracklets,efficiency,params,centrality); |
db0e2c5f | 202 | } |
203 | return kFALSE; | |
204 | } | |
205 | ||
206 | //____________________________________________________________ | |
207 | Int_t AliTRDPIDResponseObject::GetNumberOfMomentumBins(AliTRDPIDResponse::ETRDPIDMethod method) const{ | |
208 | ||
209 | if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){ | |
210 | AliError("Method does not exist"); | |
211 | return 0; | |
212 | } | |
213 | ||
ed8e1dc1 | 214 | if(fPIDReference[method]){ |
215 | return fPIDReference[method]->GetNumberOfMomentumBins(); | |
db0e2c5f | 216 | } |
217 | return 0; | |
218 | } | |
219 | ||
220 | //____________________________________________________________ | |
221 | void AliTRDPIDResponseObject::Print(const Option_t* opt) const{ | |
222 | // | |
223 | // Print content of the PID object | |
224 | // | |
225 | printf("Content of AliTRDPIDResponseObject \n\n"); | |
226 | ||
227 | for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){ | |
ed8e1dc1 | 228 | if(fPIDReference[method])fPIDReference[method]->Print(opt); |
bd58d4b9 | 229 | if(fPIDParams[method])fPIDParams[method]->Print(opt); |
db0e2c5f | 230 | } |
231 | } |