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 fkPIDParams[method]=NULL;
54 fkPIDReference[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 fkPIDParams[method]=NULL;
70 fkPIDReference[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 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
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) && fkPIDParams[method])delete fkPIDParams[method];
101 if(TestBit(kIsOwner) && fkPIDReference[method])delete fkPIDReference[method];
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
106 SetBit(kIsOwner, kFALSE);
111 //____________________________________________________________
112 AliTRDPIDResponseObject::~AliTRDPIDResponseObject(){
115 // references are deleted if the object is the owner
117 if(fkPIDParams && TestBit(kIsOwner)) delete fkPIDParams;
118 if(fkPIDReference && TestBit(kIsOwner)) delete fkPIDReference;
122 //____________________________________________________________
123 void AliTRDPIDResponseObject::SetPIDParams(AliTRDPIDParams *params,AliTRDPIDResponse::ETRDPIDMethod method){
125 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
126 AliError("Method does not exist");
129 if(fkPIDParams[method]){
130 delete fkPIDParams[method];
131 fkPIDParams[method]=NULL;
134 fkPIDParams[method]=new AliTRDPIDParams(*params);
137 //____________________________________________________________
138 void AliTRDPIDResponseObject::SetPIDReference(AliTRDPIDReference *reference,AliTRDPIDResponse::ETRDPIDMethod method){
140 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
141 AliError("Method does not exist");
144 if(fkPIDReference[method]){
145 delete fkPIDReference[method];
146 fkPIDReference[method]=NULL;
148 fkPIDReference[method]=new AliTRDPIDReference(*reference);
151 //____________________________________________________________
152 TObject *AliTRDPIDResponseObject::GetUpperReference(AliPID::EParticleType spec, Float_t p, Float_t &pUpper,AliTRDPIDResponse::ETRDPIDMethod method) const{
154 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
155 AliError("Method does not exist");
159 if(fkPIDReference[method]){
160 return fkPIDReference[method]->GetUpperReference(spec,p,pUpper);
166 //____________________________________________________________
167 TObject *AliTRDPIDResponseObject::GetLowerReference(AliPID::EParticleType spec, Float_t p, Float_t &pLower,AliTRDPIDResponse::ETRDPIDMethod method) const{
169 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
170 AliError("Method does not exist");
174 if(fkPIDReference[method]){
175 return fkPIDReference[method]->GetLowerReference(spec,p,pLower);
180 //____________________________________________________________
181 Bool_t AliTRDPIDResponseObject::GetThresholdParameters(Int_t ntracklets, Double_t efficiency, Double_t *params,AliTRDPIDResponse::ETRDPIDMethod method) const{
183 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
184 AliError("Method does not exist");
188 if(fkPIDParams[method]){
189 return fkPIDParams[method]->GetThresholdParameters(ntracklets,efficiency,params);
194 //____________________________________________________________
195 Int_t AliTRDPIDResponseObject::GetNumberOfMomentumBins(AliTRDPIDResponse::ETRDPIDMethod method) const{
197 if(Int_t(method)>=Int_t(AliTRDPIDResponse::kNMethod)||Int_t(method)<0){
198 AliError("Method does not exist");
202 if(fkPIDReference[method]){
203 return fkPIDReference[method]->GetNumberOfMomentumBins();
208 //____________________________________________________________
209 void AliTRDPIDResponseObject::Print(const Option_t* opt) const{
211 // Print content of the PID object
213 printf("Content of AliTRDPIDResponseObject \n\n");
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");