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 ///////////////////////////////////////////////////////////////////////////
20 // Handling of ALICE (extrapolated) signals.
24 // Signal positions (r) and reference frames (f) are specified via
25 // SetPosition(r,f) under the following conventions :
27 // f="car" ==> r is Cartesian (x,y,z)
28 // f="sph" ==> r is Spherical (r,theta,phi)
29 // f="cyl" ==> r is Cylindrical (rho,phi,z)
31 // The same holds for SetPositionErrors().
33 // All angles are in radians.
39 // s.SetName("Start counter");
40 // Float_t pos[3]={-1,25,7};
41 // Float_t err[3]={0.03,0.7,0.18};
42 // Float_t signal=120.8;
43 // Float_t error=1.73;
44 // s.SetPosition(pos,"car");
45 // s.SetPositionErrors(err,"car");
46 // s.SetSignal(signal);
47 // s.SetSignalError(error);
48 // Float_t loc[3],dr[3],sigma;
49 // s.GetPosition(loc,"sph");
50 // s.GetPositionErrors(dr,"sph");
51 // Float_t adc=s.GetSignal();
52 // Float_t sigma=s.GetSignalError();
54 // AliSignal q(3); // q can store 3 signal values with their errors
55 // // In the example below a signal contains the
56 // // following data : timing, ADC and dE/dx
57 // q.SetName("TOF hit");
58 // q.SetPosition(pos,"car");
59 // q.SetPositionErrors(err,"car");
60 // signal=82.5; // e.g. signal time in ns
62 // q.SetSignal(signal,1);
63 // q.SetSignalError(error,1);
64 // signal=268.1; // e.g. ADC value of signal
66 // q.SetSignal(signal,2);
67 // q.SetSignalError(error,2);
68 // signal=23.7; // e.g. corresponding dE/dx value
70 // q.SetSignal(signal,3);
71 // q.SetSignalError(error,3);
73 //--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht
74 //- Modified: NvE $Date$ UU-SAP Utrecht
75 ///////////////////////////////////////////////////////////////////////////
77 #include "AliSignal.h"
79 ClassImp(AliSignal) // Class implementation to enable ROOT I/O
81 AliSignal::AliSignal(Int_t n)
83 // Creation of an AliSignal object and initialisation of parameters.
84 // A total of n (default n=1) values (with errors) can be stored.
90 ///////////////////////////////////////////////////////////////////////////
91 AliSignal::~AliSignal()
93 // Destructor to delete dynamically allocated memory
105 ///////////////////////////////////////////////////////////////////////////
106 void AliSignal::Reset()
108 // Reset all signal and position values and errors to 0.
109 // The data arrays are also created if not already existing.
111 if (!fSignal) fSignal=new TArrayF(fNvalues);
112 if (!fDsignal) fDsignal=new TArrayF(fNvalues);
114 Double_t r[3]={0,0,0};
115 SetPosition(r,"sph");
117 for (Int_t i=0; i<fSignal->GetSize(); i++)
120 fDsignal->AddAt(0,i);
123 ///////////////////////////////////////////////////////////////////////////
124 void AliSignal::ResetSignals()
126 // Reset all signal values and errors to 0.
127 // The data arrays are also created if not already existing.
129 if (!fSignal) fSignal=new TArrayF(fNvalues);
130 if (!fDsignal) fDsignal=new TArrayF(fNvalues);
132 for (Int_t i=0; i<fSignal->GetSize(); i++)
135 fDsignal->AddAt(0,i);
138 ///////////////////////////////////////////////////////////////////////////
139 void AliSignal::ResetPosition()
141 // Reset position and errors to 0.
142 Double_t r[3]={0,0,0};
143 SetPosition(r,"sph");
146 ///////////////////////////////////////////////////////////////////////////
147 void AliSignal::SetSignal(Double_t sig,Int_t j)
149 // Store j-th (default j=1) signal value.
150 // Note : The first signal value is at j=1.
152 if (!fSignal) ResetSignals();
154 Int_t size=fSignal->GetSize();
157 fSignal->AddAt(float(sig),j-1);
161 cout << "*AliSignal::SetSignal* Index mismatch j : " << j
162 << " size : " << size << endl;
165 ///////////////////////////////////////////////////////////////////////////
166 void AliSignal::AddSignal(Double_t sig,Int_t j)
168 // Add value to j-th (default j=1) signal value.
169 // Note : The first signal value is at j=1.
171 if (!fSignal) ResetSignals();
173 Int_t size=fSignal->GetSize();
176 Float_t sum=(fSignal->At(j-1))+sig;
177 fSignal->AddAt(sum,j-1);
181 cout << "*AliSignal::AddSignal* Index mismatch j : " << j
182 << " size : " << size << endl;
185 ///////////////////////////////////////////////////////////////////////////
186 Float_t AliSignal::GetSignal(Int_t j)
188 // Provide j-th (default j=1) signal value.
189 // Note : The first signal value is at j=1.
192 return fSignal->At(j-1);
199 ///////////////////////////////////////////////////////////////////////////
200 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
202 // Store error on j-th (default j=1) signal value.
203 // Note : The error on the first signal value is at j=1.
205 if (!fDsignal) ResetSignals();
207 Int_t size=fDsignal->GetSize();
210 fDsignal->AddAt(float(dsig),j-1);
214 cout << "*AliSignal::SetSignalError* Index mismatch j : " << j
215 << " size : " << size << endl;
218 ///////////////////////////////////////////////////////////////////////////
219 Float_t AliSignal::GetSignalError(Int_t j)
221 // Provide error on the j-th (default j=1) signal value.
222 // Note : The error on the first signal value is at j=1.
225 return fDsignal->At(j-1);
232 ///////////////////////////////////////////////////////////////////////////
233 void AliSignal::Info(TString f)
235 // Provide signal information within the coordinate frame f
236 cout << " *AliSignal::Info* For signal of kind : " << fName << endl;
240 if (fSignal && fDsignal)
242 for (Int_t i=0; i<fSignal->GetSize(); i++)
244 cout << " Signal value : " << fSignal->At(i)
245 << " error : " << fDsignal->At(i) << endl;
249 ///////////////////////////////////////////////////////////////////////////
250 void AliSignal::SetName(TString name)
252 // Set the name tag to indicate the kind of signal.
255 ///////////////////////////////////////////////////////////////////////////
256 TString AliSignal::GetName()
258 // Provide the name tag indicating the kind of signal.
261 ///////////////////////////////////////////////////////////////////////////