1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
24 // Markus Fasel <M.Fasel@gsi.de>
25 // Daniel Lohner <Daniel.Lohner@cern.ch>
29 #include "AliTRDPIDResponseObject.h"
31 #ifndef AliTRDPIDREFERENCE_H
32 #include "AliTRDPIDReference.h"
35 #ifndef AliTRDPIDPARAMS_H
36 #include "AliTRDPIDParams.h"
40 ClassImp(AliTRDPIDResponseObject)
42 //____________________________________________________________
43 AliTRDPIDResponseObject::AliTRDPIDResponseObject():
50 SetBit(kIsOwner, kTRUE);
52 for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
53 fPIDParams[method]=NULL;
54 fPIDReference[method]=NULL;
58 //____________________________________________________________
59 AliTRDPIDResponseObject::AliTRDPIDResponseObject(const Char_t *name):
60 TNamed(name, "TRD PID Response Object"),
64 // Default constructor
66 SetBit(kIsOwner, kTRUE);
68 for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
69 fPIDParams[method]=NULL;
70 fPIDReference[method]=NULL;
74 //____________________________________________________________
75 AliTRDPIDResponseObject::AliTRDPIDResponseObject(const AliTRDPIDResponseObject &ref):
77 fNSlicesQ0(ref.fNSlicesQ0)
81 // Only copies pointers, object is not the owner of the references
83 SetBit(kIsOwner, kFALSE);
85 for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
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
90 //____________________________________________________________
91 AliTRDPIDResponseObject &AliTRDPIDResponseObject::operator=(const AliTRDPIDResponseObject &ref){
93 // Assginment operator
94 // Only copies poiters, object is not the owner of the references
97 TNamed::operator=(ref);
98 fNSlicesQ0=ref.fNSlicesQ0;
99 for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
100 if(TestBit(kIsOwner) && fPIDParams[method]){
101 delete fPIDParams[method];
102 fPIDParams[method]= 0;
104 if(TestBit(kIsOwner) && fPIDReference[method]){
105 delete fPIDReference[method];
106 fPIDReference[method] = 0;
108 printf("Assignment");
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
112 SetBit(kIsOwner, kFALSE);
117 //____________________________________________________________
118 AliTRDPIDResponseObject::~AliTRDPIDResponseObject(){
121 // references are deleted if the object is the owner
123 for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
124 if(fPIDParams[method] && TestBit(kIsOwner)){
125 delete fPIDParams[method];fPIDParams[method] = 0;
127 if(fPIDReference[method] && TestBit(kIsOwner)){
128 delete fPIDReference[method];
129 fPIDReference[method] = 0;
134 //____________________________________________________________
135 void AliTRDPIDResponseObject::SetPIDParams(AliTRDPIDParams *params,AliTRDPIDResponse::ETRDPIDMethod method){
137 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
138 AliError("Method does not exist");
141 if(fPIDParams[method]){
142 delete fPIDParams[method];
143 fPIDParams[method]=NULL;
146 fPIDParams[method]=new AliTRDPIDParams(*params);
149 //____________________________________________________________
150 void AliTRDPIDResponseObject::SetPIDReference(AliTRDPIDReference *reference,AliTRDPIDResponse::ETRDPIDMethod method){
152 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
153 AliError("Method does not exist");
156 if(fPIDReference[method]){
157 delete fPIDReference[method];
158 fPIDReference[method]=NULL;
160 fPIDReference[method]=new AliTRDPIDReference(*reference);
163 //____________________________________________________________
164 TObject *AliTRDPIDResponseObject::GetUpperReference(AliPID::EParticleType spec, Float_t p, Float_t &pUpper,AliTRDPIDResponse::ETRDPIDMethod method) const{
166 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
167 AliError("Method does not exist");
171 if(fPIDReference[method]){
172 return fPIDReference[method]->GetUpperReference(spec,p,pUpper);
178 //____________________________________________________________
179 TObject *AliTRDPIDResponseObject::GetLowerReference(AliPID::EParticleType spec, Float_t p, Float_t &pLower,AliTRDPIDResponse::ETRDPIDMethod method) const{
181 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
182 AliError("Method does not exist");
186 if(fPIDReference[method]){
187 return fPIDReference[method]->GetLowerReference(spec,p,pLower);
192 //____________________________________________________________
193 Bool_t AliTRDPIDResponseObject::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params,Double_t centrality,AliTRDPIDResponse::ETRDPIDMethod method) const{
195 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
196 AliError("Method does not exist");
200 if(fPIDParams[method]){
201 return fPIDParams[method]->GetThresholdParameters(ntracklets,efficiency,params,centrality);
203 AliError("TRD Threshold Container does not exist");
207 //____________________________________________________________
208 Int_t AliTRDPIDResponseObject::GetNumberOfMomentumBins(AliTRDPIDResponse::ETRDPIDMethod method) const{
210 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
211 AliError("Method does not exist");
215 if(fPIDReference[method]){
216 return fPIDReference[method]->GetNumberOfMomentumBins();
221 //____________________________________________________________
222 void AliTRDPIDResponseObject::Print(const Option_t* opt) const{
224 // Print content of the PID object
226 printf("Content of AliTRDPIDResponseObject \n\n");
228 for(Int_t method=0;method<AliTRDPIDResponse::kNMethod;method++){
229 if(fPIDReference[method])fPIDReference[method]->Print(opt);
230 if(fPIDParams[method])fPIDParams[method]->Print(opt);