]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliTRDPIDResponseObject.cxx
566fa908892876bf20f530ff557b527a5f92f8a3
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliTRDPIDResponseObject.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 // 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++){
53         fkPIDParams[method]=NULL;
54         fkPIDReference[method]=NULL;
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++){
69             fkPIDParams[method]=NULL;
70             fkPIDReference[method]=NULL;
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++){
86         fkPIDParams[method]=ref.fkPIDParams[method];       // new Object is not owner, copy only pointer
87         fkPIDReference[method]=ref.fkPIDReference[method];    // new Object is not owner, copy only pointer
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++){
100                 if(TestBit(kIsOwner) && fkPIDParams[method])delete fkPIDParams[method];
101                 if(TestBit(kIsOwner) && fkPIDReference[method])delete fkPIDReference[method];
102
103                 fkPIDParams[method]=ref.fkPIDParams[method];       // new Object is not owner, copy only pointer
104                 fkPIDReference[method]=ref.fkPIDReference[method];    // new Object is not owner, copy only pointer
105             }
106             SetBit(kIsOwner, kFALSE);
107         }
108         return *this;
109 }
110
111 //____________________________________________________________
112 AliTRDPIDResponseObject::~AliTRDPIDResponseObject(){
113         //
114         // Destructor
115         // references are deleted if the object is the owner
116         //
117     if(fkPIDParams && TestBit(kIsOwner)) delete fkPIDParams;
118     if(fkPIDReference && TestBit(kIsOwner)) delete fkPIDReference;
119
120 }
121
122 //____________________________________________________________
123 void AliTRDPIDResponseObject::SetPIDParams(AliTRDPIDParams *params,AliTRDPIDResponse::ETRDPIDMethod method){
124
125     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
126         AliError("Method does not exist");
127         return;
128     }
129     if(fkPIDParams[method]){
130         delete fkPIDParams[method];
131         fkPIDParams[method]=NULL;
132     }
133
134     fkPIDParams[method]=new AliTRDPIDParams(*params);
135 }
136
137 //____________________________________________________________
138 void AliTRDPIDResponseObject::SetPIDReference(AliTRDPIDReference *reference,AliTRDPIDResponse::ETRDPIDMethod method){
139
140     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
141         AliError("Method does not exist");
142         return;
143     }
144     if(fkPIDReference[method]){
145         delete fkPIDReference[method];
146         fkPIDReference[method]=NULL;
147     }
148     fkPIDReference[method]=new AliTRDPIDReference(*reference);
149 }
150
151 //____________________________________________________________
152 TObject *AliTRDPIDResponseObject::GetUpperReference(AliPID::EParticleType spec, Float_t p, Float_t &pUpper,AliTRDPIDResponse::ETRDPIDMethod method) const{
153
154     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
155         AliError("Method does not exist");
156         return NULL;
157     }
158    
159     if(fkPIDReference[method]){
160         return fkPIDReference[method]->GetUpperReference(spec,p,pUpper);
161     }
162     return NULL;
163 }
164
165
166 //____________________________________________________________
167 TObject *AliTRDPIDResponseObject::GetLowerReference(AliPID::EParticleType spec, Float_t p, Float_t &pLower,AliTRDPIDResponse::ETRDPIDMethod method) const{
168
169     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
170         AliError("Method does not exist");
171         return NULL;
172     }
173
174      if(fkPIDReference[method]){
175          return fkPIDReference[method]->GetLowerReference(spec,p,pLower);
176      }
177     return NULL;
178 }
179
180 //____________________________________________________________
181 Bool_t AliTRDPIDResponseObject::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params,AliTRDPIDResponse::ETRDPIDMethod method) const{
182
183     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
184         AliError("Method does not exist");
185         return kFALSE;
186     }
187
188     if(fkPIDParams[method]){
189         return fkPIDParams[method]->GetThresholdParameters(ntracklets,efficiency,params);
190     }
191     return kFALSE;
192 }
193
194 //____________________________________________________________
195 Int_t AliTRDPIDResponseObject::GetNumberOfMomentumBins(AliTRDPIDResponse::ETRDPIDMethod method) const{
196
197     if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
198         AliError("Method does not exist");
199         return 0;
200     }
201
202     if(fkPIDReference[method]){
203         return fkPIDReference[method]->GetNumberOfMomentumBins();
204     }
205     return 0;
206 }
207
208 //____________________________________________________________
209 void AliTRDPIDResponseObject::Print(const Option_t* opt) const{
210         //
211         // Print content of the PID object
212         //
213     printf("Content of AliTRDPIDResponseObject \n\n");
214    
215     for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
216         if(fkPIDReference[method])fkPIDReference[method]->Print(opt);
217         if(fkPIDParams[method])printf("+ Threshold Parameters \n");
218     }
219 }