Missing comment lines added in SetName() and GetName() of AliCalorimeter and AliSignal.
[u/mrichter/AliRoot.git] / RALICE / AliSignal.cxx
CommitLineData
4c039060 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
f531a546 16// $Id$
4c039060 17
959fbac5 18///////////////////////////////////////////////////////////////////////////
19// Class AliSignal
20// Handling of ALICE (extrapolated) signals.
21//
22// Note :
23// ------
24// Signal positions (r) and reference frames (f) are specified via
25// SetPosition(r,f) under the following conventions :
26//
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)
30//
31// The same holds for SetPositionErrors().
32//
33// All angles are in radians.
34//
35// Example :
36// ---------
37//
38// AliSignal s;
7a5c405b 39// s.SetName("Start counter");
959fbac5 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();
53//
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
7a5c405b 57// q.SetName("TOF hit");
959fbac5 58// q.SetPosition(pos,"car");
59// q.SetPositionErrors(err,"car");
7a5c405b 60// signal=82.5; // e.g. signal time in ns
959fbac5 61// error=2.01;
62// q.SetSignal(signal,1);
63// q.SetSignalError(error,1);
64// signal=268.1; // e.g. ADC value of signal
65// error=3.75;
66// q.SetSignal(signal,2);
67// q.SetSignalError(error,2);
68// signal=23.7; // e.g. corresponding dE/dx value
69// error=0.48;
70// q.SetSignal(signal,3);
71// q.SetSignalError(error,3);
72//
73//--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht
f531a546 74//- Modified: NvE $Date$ UU-SAP Utrecht
959fbac5 75///////////////////////////////////////////////////////////////////////////
76
d88f97cc 77#include "AliSignal.h"
78
79ClassImp(AliSignal) // Class implementation to enable ROOT I/O
80
959fbac5 81AliSignal::AliSignal(Int_t n)
d88f97cc 82{
959fbac5 83// Creation of an AliSignal object and initialisation of parameters.
84// A total of n (default n=1) values (with errors) can be stored.
85 fNvalues=n;
86 fSignal=0;
87 fDsignal=0;
7a5c405b 88 fName=" ";
d88f97cc 89}
90///////////////////////////////////////////////////////////////////////////
91AliSignal::~AliSignal()
92{
93// Destructor to delete dynamically allocated memory
959fbac5 94 if (fSignal)
95 {
96 delete fSignal;
97 fSignal=0;
98 }
99 if (fDsignal)
100 {
101 delete fDsignal;
102 fDsignal=0;
103 }
d88f97cc 104}
105///////////////////////////////////////////////////////////////////////////
106void AliSignal::Reset()
107{
959fbac5 108// Reset all signal and position values and errors to 0.
109// The data arrays are also created if not already existing.
110
111 if (!fSignal) fSignal=new TArrayF(fNvalues);
112 if (!fDsignal) fDsignal=new TArrayF(fNvalues);
113
114 Double_t r[3]={0,0,0};
d88f97cc 115 SetPosition(r,"sph");
959fbac5 116 SetErrors(r,"car");
117 for (Int_t i=0; i<fSignal->GetSize(); i++)
118 {
119 fSignal->AddAt(0,i);
120 fDsignal->AddAt(0,i);
121 }
122}
123///////////////////////////////////////////////////////////////////////////
124void AliSignal::ResetSignals()
125{
126// Reset all signal values and errors to 0.
127// The data arrays are also created if not already existing.
128
129 if (!fSignal) fSignal=new TArrayF(fNvalues);
130 if (!fDsignal) fDsignal=new TArrayF(fNvalues);
131
132 for (Int_t i=0; i<fSignal->GetSize(); i++)
133 {
134 fSignal->AddAt(0,i);
135 fDsignal->AddAt(0,i);
136 }
d88f97cc 137}
138///////////////////////////////////////////////////////////////////////////
959fbac5 139void AliSignal::ResetPosition()
d88f97cc 140{
959fbac5 141// Reset position and errors to 0.
142 Double_t r[3]={0,0,0};
143 SetPosition(r,"sph");
144 SetErrors(r,"car");
d88f97cc 145}
146///////////////////////////////////////////////////////////////////////////
959fbac5 147void AliSignal::SetSignal(Double_t sig,Int_t j)
d88f97cc 148{
959fbac5 149// Store j-th (default j=1) signal value.
150// Note : The first signal value is at j=1.
151
152 if (!fSignal) ResetSignals();
153
154 Int_t size=fSignal->GetSize();
155 if (j<=size)
156 {
157 fSignal->AddAt(float(sig),j-1);
158 }
159 else
160 {
161 cout << "*AliSignal::SetSignal* Index mismatch j : " << j
162 << " size : " << size << endl;
163 }
d88f97cc 164}
165///////////////////////////////////////////////////////////////////////////
959fbac5 166void AliSignal::AddSignal(Double_t sig,Int_t j)
167{
168// Add value to j-th (default j=1) signal value.
169// Note : The first signal value is at j=1.
170
171 if (!fSignal) ResetSignals();
172
173 Int_t size=fSignal->GetSize();
174 if (j<=size)
175 {
176 Float_t sum=(fSignal->At(j-1))+sig;
177 fSignal->AddAt(sum,j-1);
178 }
179 else
180 {
181 cout << "*AliSignal::AddSignal* Index mismatch j : " << j
182 << " size : " << size << endl;
183 }
184}
185///////////////////////////////////////////////////////////////////////////
186Float_t AliSignal::GetSignal(Int_t j)
187{
188// Provide j-th (default j=1) signal value.
189// Note : The first signal value is at j=1.
190 if (fSignal)
191 {
192 return fSignal->At(j-1);
193 }
194 else
195 {
196 return 0;
197 }
198}
199///////////////////////////////////////////////////////////////////////////
200void AliSignal::SetSignalError(Double_t dsig,Int_t j)
201{
202// Store error on j-th (default j=1) signal value.
203// Note : The error on the first signal value is at j=1.
204
205 if (!fDsignal) ResetSignals();
206
207 Int_t size=fDsignal->GetSize();
208 if (j<=size)
209 {
210 fDsignal->AddAt(float(dsig),j-1);
211 }
212 else
213 {
214 cout << "*AliSignal::SetSignalError* Index mismatch j : " << j
215 << " size : " << size << endl;
216 }
217}
218///////////////////////////////////////////////////////////////////////////
219Float_t AliSignal::GetSignalError(Int_t j)
220{
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.
223 if (fDsignal)
224 {
225 return fDsignal->At(j-1);
226 }
227 else
228 {
229 return 0;
230 }
231}
232///////////////////////////////////////////////////////////////////////////
233void AliSignal::Info(TString f)
234{
235// Provide signal information within the coordinate frame f
7a5c405b 236 cout << " *AliSignal::Info* For signal of kind : " << fName << endl;
959fbac5 237 cout << " Position";
238 Ali3Vector::Info(f);
239
240 if (fSignal && fDsignal)
241 {
242 for (Int_t i=0; i<fSignal->GetSize(); i++)
243 {
244 cout << " Signal value : " << fSignal->At(i)
245 << " error : " << fDsignal->At(i) << endl;
246 }
247 }
248}
249///////////////////////////////////////////////////////////////////////////
7a5c405b 250void AliSignal::SetName(TString name)
251{
b31dbd22 252// Set the name tag to indicate the kind of signal.
7a5c405b 253 fName=name;
254}
255///////////////////////////////////////////////////////////////////////////
256TString AliSignal::GetName()
257{
b31dbd22 258// Provide the name tag indicating the kind of signal.
7a5c405b 259 return fName;
260}
261///////////////////////////////////////////////////////////////////////////