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 **************************************************************************/
18 Revision 1.2 1999/09/29 09:24:28 fca
19 Introduction of the Copyright and cvs Log
23 ///////////////////////////////////////////////////////////////////////////
25 // Handling of ALICE (extrapolated) signals.
29 // Signal positions (r) and reference frames (f) are specified via
30 // SetPosition(r,f) under the following conventions :
32 // f="car" ==> r is Cartesian (x,y,z)
33 // f="sph" ==> r is Spherical (r,theta,phi)
34 // f="cyl" ==> r is Cylindrical (rho,phi,z)
36 // The same holds for SetPositionErrors().
38 // All angles are in radians.
44 // Float_t pos[3]={-1,25,7};
45 // Float_t err[3]={0.03,0.7,0.18};
46 // Float_t signal=120.8;
47 // Float_t error=1.73;
48 // s.SetPosition(pos,"car");
49 // s.SetPositionErrors(err,"car");
50 // s.SetSignal(signal);
51 // s.SetSignalError(error);
52 // Float_t loc[3],dr[3],sigma;
53 // s.GetPosition(loc,"sph");
54 // s.GetPositionErrors(dr,"sph");
55 // Float_t adc=s.GetSignal();
56 // Float_t sigma=s.GetSignalError();
58 // AliSignal q(3); // q can store 3 signal values with their errors
59 // // In the example below a signal contains the
60 // // following data : timing, ADC and dE/dx
61 // q.SetPosition(pos,"car");
62 // q.SetPositionErrors(err,"car");
63 // signal=82.5; // e.q. signal time in ns
65 // q.SetSignal(signal,1);
66 // q.SetSignalError(error,1);
67 // signal=268.1; // e.g. ADC value of signal
69 // q.SetSignal(signal,2);
70 // q.SetSignalError(error,2);
71 // signal=23.7; // e.g. corresponding dE/dx value
73 // q.SetSignal(signal,3);
74 // q.SetSignalError(error,3);
76 //--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht
77 //- Modified: NvE 30-oct-1999 UU-SAP Utrecht
78 ///////////////////////////////////////////////////////////////////////////
80 #include "AliSignal.h"
82 ClassImp(AliSignal) // Class implementation to enable ROOT I/O
84 AliSignal::AliSignal(Int_t n)
86 // Creation of an AliSignal object and initialisation of parameters.
87 // A total of n (default n=1) values (with errors) can be stored.
92 ///////////////////////////////////////////////////////////////////////////
93 AliSignal::~AliSignal()
95 // Destructor to delete dynamically allocated memory
107 ///////////////////////////////////////////////////////////////////////////
108 void AliSignal::Reset()
110 // Reset all signal and position values and errors to 0.
111 // The data arrays are also created if not already existing.
113 if (!fSignal) fSignal=new TArrayF(fNvalues);
114 if (!fDsignal) fDsignal=new TArrayF(fNvalues);
116 Double_t r[3]={0,0,0};
117 SetPosition(r,"sph");
119 for (Int_t i=0; i<fSignal->GetSize(); i++)
122 fDsignal->AddAt(0,i);
125 ///////////////////////////////////////////////////////////////////////////
126 void AliSignal::ResetSignals()
128 // Reset all signal values and errors to 0.
129 // The data arrays are also created if not already existing.
131 if (!fSignal) fSignal=new TArrayF(fNvalues);
132 if (!fDsignal) fDsignal=new TArrayF(fNvalues);
134 for (Int_t i=0; i<fSignal->GetSize(); i++)
137 fDsignal->AddAt(0,i);
140 ///////////////////////////////////////////////////////////////////////////
141 void AliSignal::ResetPosition()
143 // Reset position and errors to 0.
144 Double_t r[3]={0,0,0};
145 SetPosition(r,"sph");
148 ///////////////////////////////////////////////////////////////////////////
149 void AliSignal::SetSignal(Double_t sig,Int_t j)
151 // Store j-th (default j=1) signal value.
152 // Note : The first signal value is at j=1.
154 if (!fSignal) ResetSignals();
156 Int_t size=fSignal->GetSize();
159 fSignal->AddAt(float(sig),j-1);
163 cout << "*AliSignal::SetSignal* Index mismatch j : " << j
164 << " size : " << size << endl;
167 ///////////////////////////////////////////////////////////////////////////
168 void AliSignal::AddSignal(Double_t sig,Int_t j)
170 // Add value to j-th (default j=1) signal value.
171 // Note : The first signal value is at j=1.
173 if (!fSignal) ResetSignals();
175 Int_t size=fSignal->GetSize();
178 Float_t sum=(fSignal->At(j-1))+sig;
179 fSignal->AddAt(sum,j-1);
183 cout << "*AliSignal::AddSignal* Index mismatch j : " << j
184 << " size : " << size << endl;
187 ///////////////////////////////////////////////////////////////////////////
188 Float_t AliSignal::GetSignal(Int_t j)
190 // Provide j-th (default j=1) signal value.
191 // Note : The first signal value is at j=1.
194 return fSignal->At(j-1);
201 ///////////////////////////////////////////////////////////////////////////
202 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
204 // Store error on j-th (default j=1) signal value.
205 // Note : The error on the first signal value is at j=1.
207 if (!fDsignal) ResetSignals();
209 Int_t size=fDsignal->GetSize();
212 fDsignal->AddAt(float(dsig),j-1);
216 cout << "*AliSignal::SetSignalError* Index mismatch j : " << j
217 << " size : " << size << endl;
220 ///////////////////////////////////////////////////////////////////////////
221 Float_t AliSignal::GetSignalError(Int_t j)
223 // Provide error on the j-th (default j=1) signal value.
224 // Note : The error on the first signal value is at j=1.
227 return fDsignal->At(j-1);
234 ///////////////////////////////////////////////////////////////////////////
235 void AliSignal::Info(TString f)
237 // Provide signal information within the coordinate frame f
238 cout << " *AliSignal::Info* " << endl;
242 if (fSignal && fDsignal)
244 for (Int_t i=0; i<fSignal->GetSize(); i++)
246 cout << " Signal value : " << fSignal->At(i)
247 << " error : " << fDsignal->At(i) << endl;
251 ///////////////////////////////////////////////////////////////////////////