]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliDetectorPID.cxx
New PID Classes
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliDetectorPID.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 ///////////////////////////////////////////////////////////////////////////
18 //                       Detector PID                                    //
19 //                                                                       //
20 //                                                                       //
21 /*
22
23 This class is supposed to store the detector pid values for all detectors
24   and all particle species.
25 It is meant to be used to buffer the PID values as a transient object in
26   AliESDtrack and AliAODTrack, respectively.
27 The calculation filling and association to the track is done in
28   AliAnalysisTaskPID response.
29 The idea of this object is to save computing time in an analysis train with
30   many analyses where access to pid is done often
31
32
33
34 */
35 //                                                                       //
36 ///////////////////////////////////////////////////////////////////////////
37
38 #include "AliPIDValues.h"
39
40 #include "AliDetectorPID.h"
41
42 ClassImp(AliDetectorPID)
43
44
45 AliDetectorPID::AliDetectorPID() :
46   TObject(),
47   fArrNsigmas("AliPIDValues",AliPIDResponse::kNdetectors),
48   fArrRawProbabilities("AliPIDValues",AliPIDResponse::kNdetectors)
49 {
50   //
51   // default constructor
52   //
53   
54 }
55
56 //_______________________________________________________________________
57 AliDetectorPID::AliDetectorPID(const AliDetectorPID &pid) :
58   TObject(pid),
59   fArrNsigmas(pid.fArrNsigmas),
60   fArrRawProbabilities(pid.fArrRawProbabilities)
61 {
62   //
63   // copy constructor
64   //
65   
66 }
67
68 //_______________________________________________________________________
69 AliDetectorPID::~AliDetectorPID()
70 {
71   //
72   // destructor
73   //
74   fArrNsigmas.Delete();
75   fArrRawProbabilities.Delete();
76 }
77
78 //_______________________________________________________________________
79 AliDetectorPID& AliDetectorPID::operator= (const AliDetectorPID &pid)
80 {
81   //
82   // assignment operator
83   //
84   
85   if (this==&pid) return *this;
86
87   TObject::operator=(pid);
88   
89   fArrNsigmas.Clear();
90   fArrRawProbabilities.Clear();
91   
92   AliPIDValues *val=0x0;
93   for (Int_t idet=0; idet<(Int_t)AliPIDResponse::kNdetectors; ++idet){
94     val=static_cast<AliPIDValues*>(pid.fArrNsigmas.UncheckedAt(idet));
95     if (val) new (fArrNsigmas[idet]) AliPIDValues(*val);
96
97     val=static_cast<AliPIDValues*>(pid.fArrRawProbabilities.UncheckedAt(idet));
98     if (val) new (fArrRawProbabilities[idet]) AliPIDValues(*val);
99   }
100
101   return *this;
102 }
103
104 //_______________________________________________________________________
105 void AliDetectorPID::SetRawProbability(AliPIDResponse::EDetector det, const Double_t prob[],
106                                        Int_t nspecies, AliPIDResponse::EDetPidStatus status)
107 {
108   //
109   // set raw probabilities for nspecies for 'det'ector
110   //
111   
112   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt(det));
113   if (!val)
114     val=new (fArrRawProbabilities[(Int_t)det]) AliPIDValues;
115
116   val->SetValues(prob,nspecies,status);
117 }
118
119 //_______________________________________________________________________
120 void AliDetectorPID::SetNumberOfSigmas(AliPIDResponse::EDetector det, const Double_t nsig[], Int_t nspecies)
121 {
122   //
123   // set number of sigmas for nspecies for 'det'ector
124   //
125   
126   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt(det));
127   if (!val)
128     val=new (fArrNsigmas[(Int_t)det]) AliPIDValues;
129
130   val->SetValues(nsig,nspecies);
131 }
132
133 //_______________________________________________________________________
134 AliPIDResponse::EDetPidStatus AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, Double_t prob[], Int_t nspecies) const
135 {
136   //
137   // get raw probabilities for nspecies for 'det'ector
138   //
139   
140   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
141   if (!val) {
142     for (Int_t i=0; i<nspecies; ++i) prob[i]=1.; //TODO: Is '1' the correct values or better 1/nspecies
143     return AliPIDResponse::kDetNoSignal;
144   }
145
146   return val->GetValues(prob,nspecies);
147 }
148
149 //_______________________________________________________________________
150 void AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, Double_t nsig[], Int_t nspecies) const
151 {
152   //
153   // get number of sigmas for nspecies for detector 'det'
154   //
155   
156   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
157   if (!val) {
158     for (Int_t i=0; i<nspecies; ++i) nsig[i]=-999.;
159     return;
160   }
161
162   val->GetValues(nsig,nspecies);
163 }
164
165 //_______________________________________________________________________
166 Double_t AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, AliPID::EParticleType type) const
167 {
168   //
169   // get 'det'ector raw probability for particle 'type'
170   //
171   
172   AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
173   if (!val) {
174     return 0.; //TODO: Is '0' the correct value?
175   }
176   
177   return val->GetValue(type);
178 }
179
180 //_______________________________________________________________________
181 Double_t AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, AliPID::EParticleType type) const
182 {
183   //
184   // get 'det'ector number of sigmas for particle 'type'
185   //
186   AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
187   if (!val) {
188     return -999.; //TODO: Is '-999.' the correct value?
189   }
190   
191   return val->GetValue(type);
192 }
193
194