]>
Commit | Line | Data |
---|---|---|
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 | |
dafe31a2 | 20 | // Generic handling of (extrapolated) detector signals. |
959fbac5 | 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; | |
1fbffa23 | 44 | // Float_t offset=-12.78; |
45 | // Float_t gain=250; | |
959fbac5 | 46 | // s.SetPosition(pos,"car"); |
47 | // s.SetPositionErrors(err,"car"); | |
48 | // s.SetSignal(signal); | |
49 | // s.SetSignalError(error); | |
1fbffa23 | 50 | // s.SetOffset(offset); |
51 | // s.SetGain(gain); | |
959fbac5 | 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(); | |
57 | // | |
c72198f1 | 58 | // AliSignal q; // In the example below a signal contains the |
959fbac5 | 59 | // // following data : timing, ADC and dE/dx |
965bd237 | 60 | // q.SetNameTitle("Hybrid","Test for multiple signal data"); |
959fbac5 | 61 | // q.SetPosition(pos,"car"); |
62 | // q.SetPositionErrors(err,"car"); | |
7a5c405b | 63 | // signal=82.5; // e.g. signal time in ns |
959fbac5 | 64 | // error=2.01; |
1fbffa23 | 65 | // offset=0.003; |
965bd237 | 66 | // q.SetSlotName("TOF"); |
959fbac5 | 67 | // q.SetSignal(signal,1); |
68 | // q.SetSignalError(error,1); | |
1fbffa23 | 69 | // q.SetOffset(offset,1); |
959fbac5 | 70 | // signal=268.1; // e.g. ADC value of signal |
71 | // error=3.75; | |
1fbffa23 | 72 | // gain=120.78; |
965bd237 | 73 | // // Addressing via name specification instead of index |
74 | // q.SetSlotName("ADC"); | |
75 | // q.SetSignal(signal,"ADC"); | |
76 | // q.SetSignalError(error,"ADC"); | |
77 | // q.SetGain(gain,"ADC"); | |
959fbac5 | 78 | // signal=23.7; // e.g. corresponding dE/dx value |
79 | // error=0.48; | |
1fbffa23 | 80 | // offset=0.2; |
81 | // gain=150; | |
965bd237 | 82 | // q.SetSlotName("dE/dx"); |
959fbac5 | 83 | // q.SetSignal(signal,3); |
84 | // q.SetSignalError(error,3); | |
1fbffa23 | 85 | // q.SetOffset(offset,3); |
86 | // q.SetGain(gain,3); | |
959fbac5 | 87 | // |
965bd237 | 88 | // Float_t dedx=q.GetSignal("dE/dx"); |
89 | // | |
959fbac5 | 90 | //--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht |
f531a546 | 91 | //- Modified: NvE $Date$ UU-SAP Utrecht |
959fbac5 | 92 | /////////////////////////////////////////////////////////////////////////// |
93 | ||
d88f97cc | 94 | #include "AliSignal.h" |
5f25234b | 95 | #include "AliTrack.h" |
c72198f1 | 96 | #include "Riostream.h" |
d88f97cc | 97 | |
98 | ClassImp(AliSignal) // Class implementation to enable ROOT I/O | |
99 | ||
1c01b4f8 | 100 | AliSignal::AliSignal() : TNamed(),AliPosition(),AliAttrib() |
d88f97cc | 101 | { |
959fbac5 | 102 | // Creation of an AliSignal object and initialisation of parameters. |
1fbffa23 | 103 | // Several signal values (with errors) can be stored in different slots. |
fdadc78a | 104 | // If needed, the storage for values (and errors) will be expanded automatically |
105 | // when entering values and/or errors. | |
1fbffa23 | 106 | fSignals=0; |
107 | fDsignals=0; | |
108 | fWaveforms=0; | |
5f25234b | 109 | fLinks=0; |
965bd237 | 110 | fDevice=0; |
d88f97cc | 111 | } |
112 | /////////////////////////////////////////////////////////////////////////// | |
113 | AliSignal::~AliSignal() | |
114 | { | |
115 | // Destructor to delete dynamically allocated memory | |
1fbffa23 | 116 | if (fSignals) |
959fbac5 | 117 | { |
1fbffa23 | 118 | delete fSignals; |
119 | fSignals=0; | |
959fbac5 | 120 | } |
1fbffa23 | 121 | if (fDsignals) |
959fbac5 | 122 | { |
1fbffa23 | 123 | delete fDsignals; |
124 | fDsignals=0; | |
959fbac5 | 125 | } |
1fbffa23 | 126 | if (fWaveforms) |
c72198f1 | 127 | { |
1fbffa23 | 128 | delete fWaveforms; |
129 | fWaveforms=0; | |
c72198f1 | 130 | } |
5f25234b | 131 | if (fLinks) |
132 | { | |
133 | delete fLinks; | |
134 | fLinks=0; | |
135 | } | |
d88f97cc | 136 | } |
137 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 138 | AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s) |
8e8e6c7f | 139 | { |
140 | // Copy constructor | |
1fbffa23 | 141 | fSignals=0; |
142 | fDsignals=0; | |
1fbffa23 | 143 | fWaveforms=0; |
5f25234b | 144 | fLinks=0; |
8e8e6c7f | 145 | |
965bd237 | 146 | // Don't copy the owning device pointer for the copy |
147 | fDevice=0; | |
148 | ||
1fbffa23 | 149 | Int_t n=s.GetNvalues(); |
150 | Double_t val; | |
151 | for (Int_t i=1; i<=n; i++) | |
8e8e6c7f | 152 | { |
1fbffa23 | 153 | val=s.GetSignal(i); |
154 | SetSignal(val,i); | |
fdadc78a | 155 | } |
156 | ||
1fbffa23 | 157 | n=s.GetNerrors(); |
158 | for (Int_t j=1; j<=n; j++) | |
fdadc78a | 159 | { |
1fbffa23 | 160 | val=s.GetSignalError(j); |
161 | SetSignalError(val,j); | |
c72198f1 | 162 | } |
163 | ||
1fbffa23 | 164 | n=s.GetNwaveforms(); |
165 | for (Int_t k=1; k<=n; k++) | |
166 | { | |
167 | TH1F* hist=s.GetWaveform(k); | |
168 | if (hist) SetWaveform(hist,k); | |
169 | } | |
5f25234b | 170 | |
d0a8ef71 | 171 | TArrayI slotarr; |
172 | TArrayI posarr; | |
173 | TObject* dum=0; | |
174 | n=s.GetIndices(dum,slotarr,posarr); | |
175 | Int_t slot,pos; | |
176 | for (Int_t idx=0; idx<n; idx++) | |
5f25234b | 177 | { |
d0a8ef71 | 178 | slot=slotarr.At(idx); |
179 | pos=posarr.At(idx); | |
180 | TObject* obj=s.GetLink(slot,pos); | |
181 | if (obj) SetLink(obj,slot,pos); | |
5f25234b | 182 | } |
8e8e6c7f | 183 | } |
184 | /////////////////////////////////////////////////////////////////////////// | |
fdadc78a | 185 | void AliSignal::Reset(Int_t mode) |
d88f97cc | 186 | { |
959fbac5 | 187 | // Reset all signal and position values and errors to 0. |
fdadc78a | 188 | // |
189 | // mode = 0 Reset position and all signal values and their errors to 0. | |
1fbffa23 | 190 | // The waveform histograms are reset, but the calibration |
191 | // constants (i.e. gains and offsets) are kept. | |
fdadc78a | 192 | // 1 Reset position and delete the signal and error storage arrays. |
1fbffa23 | 193 | // Also the waveform histograms, gains and offset arrays are deleted. |
fdadc78a | 194 | // |
195 | // The default when invoking Reset() corresponds to mode=0. | |
196 | // | |
d0a8ef71 | 197 | // Note : In all cases the storage of the various links will be reset. |
4f368c8c | 198 | // The UniqueID, name and title will NOT be reset. |
199 | // In case the user wants to reset these attributes, this has to | |
200 | // be done explicitly via the SET facilities. | |
5f25234b | 201 | // |
fdadc78a | 202 | // The usage of mode=0 allows to re-use the allocated memory for new |
203 | // signal (and error) values. This behaviour is preferable (i.e. faster) | |
1fbffa23 | 204 | // in case the various signals always contain the same number of values |
205 | // and have the same calibration constants. | |
fdadc78a | 206 | // The usage of mode=1 is slower, but allows a more efficient memory |
207 | // occupation (and smaller output file size) in case the different | |
208 | // signals have a variable number of values. | |
209 | // | |
1fbffa23 | 210 | // For more specific actions see ResetPosition(), ResetSignals(), |
d0a8ef71 | 211 | // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(), |
212 | // DeleteWaveform() and DeleteCalibrations(). | |
c72198f1 | 213 | // |
959fbac5 | 214 | |
fdadc78a | 215 | if (mode<0 || mode>1) |
959fbac5 | 216 | { |
fdadc78a | 217 | cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl; |
218 | cout << " Default mode=0 will be used." << endl; | |
219 | mode=0; | |
220 | } | |
221 | ||
222 | ResetPosition(); | |
223 | if (!mode) | |
224 | { | |
225 | ResetSignals(); | |
226 | } | |
227 | else | |
228 | { | |
229 | DeleteSignals(); | |
1fbffa23 | 230 | DeleteCalibrations(); |
959fbac5 | 231 | } |
5f25234b | 232 | |
d0a8ef71 | 233 | if (fLinks) fLinks->Reset(); |
965bd237 | 234 | fDevice=0; |
959fbac5 | 235 | } |
236 | /////////////////////////////////////////////////////////////////////////// | |
fdadc78a | 237 | void AliSignal::ResetSignals(Int_t mode) |
959fbac5 | 238 | { |
fdadc78a | 239 | // Reset various signal data according to user selection. |
240 | // | |
241 | // mode = 0 Reset all signal values and their errors to 0. | |
242 | // 1 Reset only signal values | |
243 | // 2 Reset only signal errors | |
244 | // | |
245 | // The default when invoking ResetSignals() corresponds to mode=0. | |
c72198f1 | 246 | // |
1fbffa23 | 247 | // Irrespective of the mode, the waveform histograms are reset. |
959fbac5 | 248 | |
fdadc78a | 249 | if (mode<0 || mode>2) |
250 | { | |
251 | cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl; | |
252 | cout << " Default mode=0 will be used." << endl; | |
253 | mode=0; | |
254 | } | |
255 | ||
1fbffa23 | 256 | if (fSignals && (mode==0 || mode==1)) |
959fbac5 | 257 | { |
1fbffa23 | 258 | for (Int_t i=0; i<fSignals->GetSize(); i++) |
dafe31a2 | 259 | { |
1fbffa23 | 260 | fSignals->AddAt(0,i); |
fdadc78a | 261 | } |
262 | } | |
263 | ||
1fbffa23 | 264 | if (fDsignals && (mode==0 || mode==2)) |
fdadc78a | 265 | { |
1fbffa23 | 266 | for (Int_t j=0; j<fDsignals->GetSize(); j++) |
fdadc78a | 267 | { |
1fbffa23 | 268 | fDsignals->AddAt(0,j); |
dafe31a2 | 269 | } |
959fbac5 | 270 | } |
c72198f1 | 271 | |
1fbffa23 | 272 | ResetWaveform(0); |
d88f97cc | 273 | } |
274 | /////////////////////////////////////////////////////////////////////////// | |
fdadc78a | 275 | void AliSignal::DeleteSignals(Int_t mode) |
276 | { | |
277 | // Delete storage arrays of various signal data according to user selection. | |
278 | // | |
279 | // mode = 0 Delete arrays of both signal values and their errors. | |
280 | // 1 Delete only signal values array | |
281 | // 2 Delete only signal errors array | |
282 | // | |
283 | // The default when invoking DeleteSignals() corresponds to mode=0. | |
c72198f1 | 284 | // |
1fbffa23 | 285 | // Irrespective of the mode, the waveform histograms are deleted. |
fdadc78a | 286 | |
287 | if (mode<0 || mode>2) | |
288 | { | |
289 | cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl; | |
290 | cout << " Default mode=0 will be used." << endl; | |
291 | mode=0; | |
292 | } | |
293 | ||
1fbffa23 | 294 | if (fSignals && (mode==0 || mode==1)) |
fdadc78a | 295 | { |
1fbffa23 | 296 | delete fSignals; |
297 | fSignals=0; | |
fdadc78a | 298 | } |
299 | ||
1fbffa23 | 300 | if (fDsignals && (mode==0 || mode==2)) |
fdadc78a | 301 | { |
1fbffa23 | 302 | delete fDsignals; |
303 | fDsignals=0; | |
fdadc78a | 304 | } |
c72198f1 | 305 | |
1fbffa23 | 306 | DeleteWaveform(0); |
fdadc78a | 307 | } |
308 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 309 | void AliSignal::SetSignal(Double_t sig,Int_t j) |
d88f97cc | 310 | { |
2cb7369d | 311 | // Store signal value for the j-th (default j=1) slot. |
1fbffa23 | 312 | // Note : The first signal slot is at j=1. |
dafe31a2 | 313 | // In case the value of the index j exceeds the maximum number of reserved |
fdadc78a | 314 | // slots for signal values, the number of reserved slots for the |
315 | // signal values is increased automatically. | |
959fbac5 | 316 | |
1fbffa23 | 317 | if (!fSignals) |
959fbac5 | 318 | { |
1fbffa23 | 319 | fSignals=new TArrayF(j); |
fdadc78a | 320 | ResetSignals(1); |
959fbac5 | 321 | } |
dafe31a2 | 322 | |
1fbffa23 | 323 | Int_t size=fSignals->GetSize(); |
dafe31a2 | 324 | |
325 | if (j>size) | |
959fbac5 | 326 | { |
1fbffa23 | 327 | fSignals->Set(j); |
959fbac5 | 328 | } |
dafe31a2 | 329 | |
1fbffa23 | 330 | fSignals->AddAt(float(sig),j-1); |
d88f97cc | 331 | } |
332 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 333 | void AliSignal::SetSignal(Double_t sig,TString name) |
334 | { | |
335 | // Store signal value for the name-specified slot. | |
336 | // | |
337 | // This procedure involves a slot-index search based on the specified name | |
338 | // at each invokation. This may become slow in case many slots have been | |
339 | // defined and/or when this procedure is invoked many times. | |
340 | // In such cases it is preferable to use indexed addressing in the user code | |
341 | // either directly or via a few invokations of GetSlotIndex(). | |
342 | ||
343 | Int_t j=GetSlotIndex(name); | |
344 | if (j>0) SetSignal(sig,j); | |
345 | } | |
346 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 347 | void AliSignal::AddSignal(Double_t sig,Int_t j) |
348 | { | |
2cb7369d | 349 | // Add value to the signal of the j-th (default j=1) slot. |
1fbffa23 | 350 | // Note : The first signal slot is at j=1. |
dafe31a2 | 351 | // In case the value of the index j exceeds the maximum number of reserved |
fdadc78a | 352 | // slots for signal values, the number of reserved slots for the |
353 | // signal values is increased automatically. | |
959fbac5 | 354 | |
1fbffa23 | 355 | if (!fSignals) |
959fbac5 | 356 | { |
1fbffa23 | 357 | fSignals=new TArrayF(j); |
fdadc78a | 358 | ResetSignals(1); |
959fbac5 | 359 | } |
dafe31a2 | 360 | |
1fbffa23 | 361 | Int_t size=fSignals->GetSize(); |
dafe31a2 | 362 | |
363 | if (j>size) | |
959fbac5 | 364 | { |
1fbffa23 | 365 | fSignals->Set(j); |
959fbac5 | 366 | } |
dafe31a2 | 367 | |
1fbffa23 | 368 | Float_t sum=(fSignals->At(j-1))+sig; |
369 | fSignals->AddAt(sum,j-1); | |
959fbac5 | 370 | } |
371 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 372 | void AliSignal::AddSignal(Double_t sig,TString name) |
373 | { | |
374 | // Add value to the signal of the name-specified slot. | |
375 | // | |
376 | // This procedure involves a slot-index search based on the specified name | |
377 | // at each invokation. This may become slow in case many slots have been | |
378 | // defined and/or when this procedure is invoked many times. | |
379 | // In such cases it is preferable to use indexed addressing in the user code | |
380 | // either directly or via a few invokations of GetSlotIndex(). | |
381 | ||
382 | Int_t j=GetSlotIndex(name); | |
383 | if (j>0) AddSignal(sig,j); | |
384 | } | |
385 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 386 | Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const |
959fbac5 | 387 | { |
2cb7369d | 388 | // Provide signal value of the j-th (default j=1) slot. |
1fbffa23 | 389 | // Note : The first signal slot is at j=1. |
fdadc78a | 390 | // In case no signal is present or the argument j is invalid, 0 is returned. |
1fbffa23 | 391 | // The parameter "mode" allows for automatic gain etc... correction of the signal. |
392 | // | |
393 | // mode = 0 : Just the j-th signal is returned. | |
394 | // 1 : The j-th signal is corrected for the gain, offset, dead flag etc... | |
395 | // In case the gain value was not set, gain=1 will be assumed. | |
396 | // In case the gain value was 0, a signal value of 0 is returned. | |
397 | // In case the offset value was not set, offset=0 will be assumed. | |
398 | // In case the j-th slot was marked dead, 0 is returned. | |
399 | // | |
400 | // The corrected signal (sigc) is determined as follows : | |
401 | // | |
402 | // sigc=(signal/gain)-offset | |
403 | // | |
404 | // The default is mode=0. | |
405 | ||
fdadc78a | 406 | Float_t sig=0; |
1fbffa23 | 407 | Float_t gain=1; |
408 | Float_t offset=0; | |
409 | if (fSignals) | |
959fbac5 | 410 | { |
1fbffa23 | 411 | if (j>0 && j<=(fSignals->GetSize())) |
fdadc78a | 412 | { |
1fbffa23 | 413 | sig=fSignals->At(j-1); |
414 | ||
415 | if (mode==0) return sig; | |
416 | ||
417 | // Correct the signal for the gain, offset, dead flag etc... | |
418 | if (GetDeadValue(j)) return 0; | |
419 | ||
420 | if (GetGainFlag(j)) gain=GetGain(j); | |
421 | if (GetOffsetFlag(j)) offset=GetOffset(j); | |
422 | ||
423 | if (fabs(gain)>0.) | |
424 | { | |
425 | sig=(sig/gain)-offset; | |
426 | } | |
427 | else | |
428 | { | |
429 | sig=0; | |
430 | } | |
fdadc78a | 431 | } |
432 | else | |
433 | { | |
434 | cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl; | |
435 | } | |
959fbac5 | 436 | } |
fdadc78a | 437 | return sig; |
959fbac5 | 438 | } |
439 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 440 | Float_t AliSignal::GetSignal(TString name,Int_t mode) const |
441 | { | |
442 | // Provide signal value of the name-specified slot. | |
443 | // In case no signal is present, 0 is returned. | |
444 | // The parameter "mode" allows for automatic gain etc... correction of the signal. | |
445 | // | |
446 | // mode = 0 : Just the j-th signal is returned. | |
447 | // 1 : The j-th signal is corrected for the gain, offset, dead flag etc... | |
448 | // In case the gain value was not set, gain=1 will be assumed. | |
449 | // In case the gain value was 0, a signal value of 0 is returned. | |
450 | // In case the offset value was not set, offset=0 will be assumed. | |
451 | // In case the j-th slot was marked dead, 0 is returned. | |
452 | // | |
453 | // The corrected signal (sigc) is determined as follows : | |
454 | // | |
455 | // sigc=(signal/gain)-offset | |
456 | // | |
457 | // The default is mode=0. | |
458 | // | |
459 | // This procedure involves a slot-index search based on the specified name | |
460 | // at each invokation. This may become slow in case many slots have been | |
461 | // defined and/or when this procedure is invoked many times. | |
462 | // In such cases it is preferable to use indexed addressing in the user code | |
463 | // either directly or via a few invokations of GetSlotIndex(). | |
464 | ||
465 | Int_t j=GetSlotIndex(name); | |
466 | Float_t val=0; | |
467 | if (j>0) val=GetSignal(j,mode); | |
468 | return val; | |
469 | } | |
470 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 471 | void AliSignal::SetSignalError(Double_t dsig,Int_t j) |
472 | { | |
2cb7369d | 473 | // Store error on the signal for the j-th (default j=1) slot. |
1fbffa23 | 474 | // Note : The first signal slot is at j=1. |
dafe31a2 | 475 | // In case the value of the index j exceeds the maximum number of reserved |
fdadc78a | 476 | // slots for signal error values, the number of reserved slots for the |
477 | // signal errors is increased automatically. | |
959fbac5 | 478 | |
1fbffa23 | 479 | if (!fDsignals) |
959fbac5 | 480 | { |
1fbffa23 | 481 | fDsignals=new TArrayF(j); |
fdadc78a | 482 | ResetSignals(2); |
959fbac5 | 483 | } |
dafe31a2 | 484 | |
1fbffa23 | 485 | Int_t size=fDsignals->GetSize(); |
dafe31a2 | 486 | |
487 | if (j>size) | |
959fbac5 | 488 | { |
1fbffa23 | 489 | fDsignals->Set(j); |
959fbac5 | 490 | } |
dafe31a2 | 491 | |
1fbffa23 | 492 | fDsignals->AddAt(float(dsig),j-1); |
959fbac5 | 493 | } |
494 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 495 | void AliSignal::SetSignalError(Double_t dsig,TString name) |
496 | { | |
497 | // Store error on the signal for the name-specified slot. | |
498 | // | |
499 | // This procedure involves a slot-index search based on the specified name | |
500 | // at each invokation. This may become slow in case many slots have been | |
501 | // defined and/or when this procedure is invoked many times. | |
502 | // In such cases it is preferable to use indexed addressing in the user code | |
503 | // either directly or via a few invokations of GetSlotIndex(). | |
504 | ||
505 | Int_t j=GetSlotIndex(name); | |
506 | if (j>0) SetSignalError(dsig,j); | |
507 | } | |
508 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 509 | Float_t AliSignal::GetSignalError(Int_t j) const |
959fbac5 | 510 | { |
2cb7369d | 511 | // Provide error on the signal of the j-th (default j=1) slot. |
1fbffa23 | 512 | // Note : The first signal slot is at j=1. |
fdadc78a | 513 | // In case no signal is present or the argument j is invalid, 0 is returned. |
514 | Float_t err=0; | |
1fbffa23 | 515 | if (fDsignals) |
959fbac5 | 516 | { |
1fbffa23 | 517 | if (j>0 && j<=(fDsignals->GetSize())) |
fdadc78a | 518 | { |
1fbffa23 | 519 | err=fDsignals->At(j-1); |
fdadc78a | 520 | } |
521 | else | |
522 | { | |
523 | cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl; | |
524 | } | |
959fbac5 | 525 | } |
fdadc78a | 526 | return err; |
959fbac5 | 527 | } |
528 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 529 | Float_t AliSignal::GetSignalError(TString name) const |
530 | { | |
531 | // Provide error on the signal of the name-specified slot. | |
532 | // | |
533 | // This procedure involves a slot-index search based on the specified name | |
534 | // at each invokation. This may become slow in case many slots have been | |
535 | // defined and/or when this procedure is invoked many times. | |
536 | // In such cases it is preferable to use indexed addressing in the user code | |
537 | // either directly or via a few invokations of GetSlotIndex(). | |
538 | ||
539 | Int_t j=GetSlotIndex(name); | |
540 | Float_t val=0; | |
541 | if (j>0) val=GetSignalError(j); | |
542 | return val; | |
543 | } | |
544 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 545 | void AliSignal::Data(TString f) const |
1c01b4f8 | 546 | { |
547 | // Provide all signal information within the coordinate frame f. | |
548 | ||
5f25234b | 549 | const char* name=GetName(); |
550 | const char* title=GetTitle(); | |
551 | ||
4f368c8c | 552 | cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID(); |
5f25234b | 553 | if (strlen(name)) cout << " Name : " << name; |
554 | if (strlen(title)) cout << " Title : " << title; | |
555 | cout << endl; | |
d0a8ef71 | 556 | cout << " Position"; |
1c01b4f8 | 557 | Ali3Vector::Data(f); |
965bd237 | 558 | if (fDevice) |
559 | { | |
560 | const char* devname=fDevice->GetName(); | |
561 | const char* devtitle=fDevice->GetTitle(); | |
562 | cout << " Owned by device : " << fDevice->ClassName(); | |
563 | if (strlen(devname)) cout << " Name : " << devname; | |
564 | if (strlen(devtitle)) cout << " Title : " << devtitle; | |
565 | cout << endl; | |
566 | } | |
1c01b4f8 | 567 | |
568 | List(-1); | |
569 | } | |
570 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 571 | void AliSignal::List(Int_t j) const |
959fbac5 | 572 | { |
1c01b4f8 | 573 | // Provide signal information for the j-th slot. |
1fbffa23 | 574 | // The first slot is at j=1. |
575 | // In case j=0 (default) the data of all slots will be listed. | |
1c01b4f8 | 576 | // In case j=-1 the data of all slots will be listed, but the header |
577 | // information will be suppressed. | |
1fbffa23 | 578 | |
1c01b4f8 | 579 | if (j<-1) |
1fbffa23 | 580 | { |
1c01b4f8 | 581 | cout << " *AliSignal::List* Invalid argument j = " << j << endl; |
1fbffa23 | 582 | return; |
583 | } | |
584 | ||
5f25234b | 585 | if (j != -1) |
586 | { | |
587 | const char* name=GetName(); | |
588 | const char* title=GetTitle(); | |
589 | ||
590 | cout << " *" << ClassName() << "::Data*"; | |
591 | if (strlen(name)) cout << " Name : " << name; | |
592 | if (strlen(title)) cout << " Title : " << title; | |
593 | cout << endl; | |
594 | } | |
fdadc78a | 595 | |
596 | Int_t nvalues=GetNvalues(); | |
597 | Int_t nerrors=GetNerrors(); | |
387a745b | 598 | Int_t nwforms=GetNwaveforms(); |
d0a8ef71 | 599 | Int_t nlinkslots=0; |
600 | if (fLinks) nlinkslots=fLinks->GetMaxColumn(); | |
1fbffa23 | 601 | Int_t n=nvalues; |
602 | if (nerrors>n) n=nerrors; | |
387a745b | 603 | if (nwforms>n) n=nwforms; |
d0a8ef71 | 604 | if (nlinkslots>n) n=nlinkslots; |
5f25234b | 605 | |
606 | TObject* obj=0; | |
d0a8ef71 | 607 | Int_t nrefs=0; |
608 | TArrayI posarr; | |
609 | Int_t pos; | |
fdadc78a | 610 | |
1c01b4f8 | 611 | if (j<=0) |
959fbac5 | 612 | { |
1fbffa23 | 613 | for (Int_t i=1; i<=n; i++) |
959fbac5 | 614 | { |
d0a8ef71 | 615 | cout << " Slot : " << i; |
616 | if (i<=nvalues) cout << " Signal value : " << GetSignal(i); | |
1fbffa23 | 617 | if (i<=nerrors) cout << " error : " << GetSignalError(i); |
1c01b4f8 | 618 | AliAttrib::List(i); |
1fbffa23 | 619 | cout << endl; |
5f25234b | 620 | obj=GetWaveform(i); |
621 | if (obj) | |
622 | { | |
623 | const char* wfname=obj->GetName(); | |
624 | const char* wftitle=obj->GetTitle(); | |
625 | cout << " Waveform : " << obj->ClassName(); | |
626 | if (strlen(wfname)) cout << " Name : " << wfname; | |
627 | if (strlen(wftitle)) cout << " Title : " << wftitle; | |
628 | cout << endl; | |
629 | } | |
d0a8ef71 | 630 | obj=0; |
631 | nrefs=GetIndices(obj,i,posarr); | |
632 | for (Int_t k=0; k<nrefs; k++) | |
5f25234b | 633 | { |
d0a8ef71 | 634 | pos=posarr.At(k); |
635 | obj=GetLink(i,pos); | |
636 | if (obj) | |
03b59bc9 | 637 | { |
d0a8ef71 | 638 | cout << " Link at position " << pos << " to : " << obj->ClassName(); |
639 | if (obj->InheritsFrom("TNamed")) | |
640 | { | |
641 | const char* lname=obj->GetName(); | |
642 | const char* ltitle=obj->GetTitle(); | |
643 | if (strlen(lname)) cout << " Name : " << lname; | |
644 | if (strlen(ltitle)) cout << " Title : " << ltitle; | |
645 | } | |
646 | cout << endl; | |
03b59bc9 | 647 | } |
5f25234b | 648 | } |
1fbffa23 | 649 | } |
650 | } | |
651 | else | |
652 | { | |
653 | if (j<=n) | |
654 | { | |
d0a8ef71 | 655 | cout << " Slot : " << j; |
656 | if (j<=nvalues) cout << " Signal value : " << GetSignal(j); | |
1fbffa23 | 657 | if (j<=nerrors) cout << " error : " << GetSignalError(j); |
1c01b4f8 | 658 | AliAttrib::List(j); |
fdadc78a | 659 | cout << endl; |
5f25234b | 660 | obj=GetWaveform(j); |
661 | if (obj) | |
662 | { | |
663 | const char* wfnamej=obj->GetName(); | |
664 | const char* wftitlej=obj->GetTitle(); | |
665 | cout << " Waveform : " << obj->ClassName(); | |
666 | if (strlen(wfnamej)) cout << " Name : " << wfnamej; | |
667 | if (strlen(wftitlej)) cout << " Title : " << wftitlej; | |
668 | cout << endl; | |
669 | } | |
d0a8ef71 | 670 | obj=0; |
671 | nrefs=GetIndices(obj,j,posarr); | |
672 | for (Int_t kj=0; kj<nrefs; kj++) | |
5f25234b | 673 | { |
d0a8ef71 | 674 | pos=posarr.At(kj); |
675 | obj=GetLink(j,pos); | |
676 | if (obj) | |
03b59bc9 | 677 | { |
d0a8ef71 | 678 | cout << " Link at position " << pos << " to : " << obj->ClassName(); |
679 | if (obj->InheritsFrom("TNamed")) | |
680 | { | |
681 | const char* lnamej=obj->GetName(); | |
682 | const char* ltitlej=obj->GetTitle(); | |
683 | if (strlen(lnamej)) cout << " Name : " << lnamej; | |
684 | if (strlen(ltitlej)) cout << " Title : " << ltitlej; | |
685 | } | |
686 | cout << endl; | |
03b59bc9 | 687 | } |
5f25234b | 688 | } |
959fbac5 | 689 | } |
690 | } | |
691 | } | |
692 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 693 | void AliSignal::List(TString name) const |
694 | { | |
695 | // Provide signal information for the name-specified slot. | |
696 | // | |
697 | // This procedure involves a slot-index search based on the specified name | |
698 | // at each invokation. This may become slow in case many slots have been | |
699 | // defined and/or when this procedure is invoked many times. | |
700 | // In such cases it is preferable to use indexed addressing in the user code | |
701 | // either directly or via a few invokations of GetSlotIndex(). | |
702 | ||
703 | Int_t j=GetSlotIndex(name); | |
704 | if (j>0) List(j); | |
705 | } | |
706 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 707 | Int_t AliSignal::GetNvalues() const |
8e8e6c7f | 708 | { |
709 | // Provide the number of values for this signal. | |
dafe31a2 | 710 | Int_t n=0; |
1fbffa23 | 711 | if (fSignals) n=fSignals->GetSize(); |
fdadc78a | 712 | return n; |
713 | } | |
714 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 715 | Int_t AliSignal::GetNerrors() const |
fdadc78a | 716 | { |
717 | // Provide the number specified errors on the values for this signal. | |
718 | Int_t n=0; | |
1fbffa23 | 719 | if (fDsignals) n=fDsignals->GetSize(); |
dafe31a2 | 720 | return n; |
8e8e6c7f | 721 | } |
722 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 723 | Int_t AliSignal::GetNwaveforms() const |
c72198f1 | 724 | { |
1fbffa23 | 725 | // Provide the number specified waveforms for this signal. |
726 | Int_t n=0; | |
727 | if (fWaveforms) n=fWaveforms->GetSize(); | |
728 | return n; | |
c72198f1 | 729 | } |
730 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 731 | TH1F* AliSignal::GetWaveform(Int_t j) const |
c72198f1 | 732 | { |
2cb7369d | 733 | // Provide pointer to the waveform histogram of the j-th slot. |
1fbffa23 | 734 | TH1F* waveform=0; |
735 | if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1); | |
736 | return waveform; | |
737 | } | |
738 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 739 | TH1F* AliSignal::GetWaveform(TString name) const |
740 | { | |
741 | // Provide pointer to the waveform histogram of the name-specified slot. | |
742 | // | |
743 | // This procedure involves a slot-index search based on the specified name | |
744 | // at each invokation. This may become slow in case many slots have been | |
745 | // defined and/or when this procedure is invoked many times. | |
746 | // In such cases it is preferable to use indexed addressing in the user code | |
747 | // either directly or via a few invokations of GetSlotIndex(). | |
748 | ||
749 | Int_t j=GetSlotIndex(name); | |
750 | TH1F* waveform=0; | |
751 | if (j>0) waveform=GetWaveform(j); | |
752 | return waveform; | |
753 | } | |
754 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 755 | void AliSignal::SetWaveform(TH1F* waveform,Int_t j) |
756 | { | |
2cb7369d | 757 | // Set the 1D waveform histogram for the j-th slot. |
1fbffa23 | 758 | // |
759 | // Notes : | |
760 | // The waveform of the first signal value is at j=1. | |
761 | // j=1 is the default value. | |
762 | // | |
763 | // In case the value of the index j exceeds the maximum number of reserved | |
764 | // slots for the waveforms, the number of reserved slots for the waveforms | |
765 | // is increased automatically. | |
c72198f1 | 766 | // |
1fbffa23 | 767 | // In case the histo pointer argument has the same value as the current waveform |
c72198f1 | 768 | // histogram pointer value, no action is taken since the user has already |
769 | // modified the actual histogram. | |
770 | // | |
1fbffa23 | 771 | // In case the histo pointer argument is zero, the current waveform histogram |
c72198f1 | 772 | // is deleted and the pointer set to zero. |
773 | // | |
774 | // In all other cases the current waveform histogram is deleted and a new | |
775 | // copy of the input histogram is created which becomes the current waveform | |
776 | // histogram. | |
777 | ||
1fbffa23 | 778 | if (!fWaveforms) |
779 | { | |
780 | fWaveforms=new TObjArray(j); | |
781 | fWaveforms->SetOwner(); | |
782 | } | |
783 | ||
784 | if (j > fWaveforms->GetSize()) fWaveforms->Expand(j); | |
785 | ||
786 | TH1F* hcur=(TH1F*)fWaveforms->At(j-1); | |
787 | if (waveform != hcur) | |
c72198f1 | 788 | { |
1fbffa23 | 789 | if (hcur) |
c72198f1 | 790 | { |
1fbffa23 | 791 | fWaveforms->Remove(hcur); |
792 | delete hcur; | |
793 | hcur=0; | |
794 | } | |
795 | if (waveform) | |
796 | { | |
797 | hcur=new TH1F(*waveform); | |
798 | fWaveforms->AddAt(hcur,j-1); | |
c72198f1 | 799 | } |
c72198f1 | 800 | } |
801 | } | |
802 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 803 | void AliSignal::SetWaveform(TH1F* waveform,TString name) |
804 | { | |
805 | // Set the 1D waveform histogram corresponding for the name-specified slot. | |
806 | // | |
807 | // This procedure involves a slot-index search based on the specified name | |
808 | // at each invokation. This may become slow in case many slots have been | |
809 | // defined and/or when this procedure is invoked many times. | |
810 | // In such cases it is preferable to use indexed addressing in the user code | |
811 | // either directly or via a few invokations of GetSlotIndex(). | |
812 | ||
813 | Int_t j=GetSlotIndex(name); | |
814 | if (j>0) SetWaveform(waveform,j); | |
815 | } | |
816 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 817 | void AliSignal::ResetWaveform(Int_t j) |
818 | { | |
2cb7369d | 819 | // Reset the waveform of the j-th (default j=1) slot. |
1fbffa23 | 820 | // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s). |
821 | // To actually delete the histograms from memory, use DeleteWaveform(). | |
822 | // Notes : The first signal value is at j=1. | |
823 | // j=0 ==> All waveforms will be reset. | |
824 | ||
825 | if (!fWaveforms) return; | |
826 | ||
827 | Int_t size=fWaveforms->GetSize(); | |
828 | ||
829 | if ((j>=0) && (j<=size)) | |
830 | { | |
831 | if (j) | |
832 | { | |
833 | TH1F* hwave=(TH1F*)fWaveforms->At(j-1); | |
834 | if (hwave) hwave->Reset(); | |
835 | } | |
836 | else | |
837 | { | |
838 | for (Int_t i=0; i<size; i++) | |
839 | { | |
840 | TH1F* hwave=(TH1F*)fWaveforms->At(i); | |
841 | if (hwave) hwave->Reset(); | |
842 | } | |
843 | } | |
844 | } | |
845 | else | |
846 | { | |
847 | cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl; | |
848 | return; | |
849 | } | |
850 | } | |
851 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 852 | void AliSignal::ResetWaveform(TString name) |
853 | { | |
854 | // Reset the waveform of the name-specified slot. | |
855 | // | |
856 | // This procedure involves a slot-index search based on the specified name | |
857 | // at each invokation. This may become slow in case many slots have been | |
858 | // defined and/or when this procedure is invoked many times. | |
859 | // In such cases it is preferable to use indexed addressing in the user code | |
860 | // either directly or via a few invokations of GetSlotIndex(). | |
861 | ||
862 | Int_t j=GetSlotIndex(name); | |
863 | if (j>0) ResetWaveform(j); | |
864 | } | |
865 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 866 | void AliSignal::DeleteWaveform(Int_t j) |
867 | { | |
2cb7369d | 868 | // Delete the waveform of the j-th (default j=1) slot. |
1fbffa23 | 869 | // Notes : The first signal value is at j=1. |
870 | // j=0 ==> All waveforms will be deleted. | |
871 | ||
872 | if (!fWaveforms) return; | |
873 | ||
874 | Int_t size=fWaveforms->GetSize(); | |
875 | ||
876 | if ((j>=0) && (j<=size)) | |
877 | { | |
878 | if (j) | |
879 | { | |
880 | TH1F* hwave=(TH1F*)fWaveforms->At(j-1); | |
881 | if (hwave) | |
882 | { | |
883 | fWaveforms->Remove(hwave); | |
884 | delete hwave; | |
885 | } | |
886 | } | |
887 | else | |
888 | { | |
889 | delete fWaveforms; | |
890 | fWaveforms=0; | |
891 | } | |
892 | } | |
893 | else | |
894 | { | |
895 | cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl; | |
896 | return; | |
897 | } | |
898 | } | |
899 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 900 | void AliSignal::DeleteWaveform(TString name) |
901 | { | |
902 | // Delete the waveform of the name-specified slot. | |
903 | // | |
904 | // This procedure involves a slot-index search based on the specified name | |
905 | // at each invokation. This may become slow in case many slots have been | |
906 | // defined and/or when this procedure is invoked many times. | |
907 | // In such cases it is preferable to use indexed addressing in the user code | |
908 | // either directly or via a few invokations of GetSlotIndex(). | |
909 | ||
910 | Int_t j=GetSlotIndex(name); | |
911 | if (j>0) DeleteWaveform(j); | |
912 | } | |
913 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 914 | Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const |
5f25234b | 915 | { |
d0a8ef71 | 916 | // Provide the number of links to the specified object for the j-th slot. |
917 | // If j=0 (default) all slots will be scanned for the specified object. | |
918 | // If obj=0 (default) all encountered objects for the specified slot will be counted. | |
919 | // So, invokation of the default GetNlinks() will return the total number of | |
920 | // all references to all sorts of stored objects. | |
921 | if (j<0) | |
922 | { | |
923 | cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl; | |
924 | return 0; | |
925 | } | |
926 | ||
5f25234b | 927 | Int_t n=0; |
d0a8ef71 | 928 | if (!j) |
929 | { | |
7a086578 | 930 | if (fLinks) n=fLinks->GetNrefs(obj); |
d0a8ef71 | 931 | } |
932 | else | |
933 | { | |
934 | TArrayI posarr; | |
935 | n=GetIndices(obj,j,posarr); | |
936 | } | |
5f25234b | 937 | return n; |
938 | } | |
939 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 940 | Int_t AliSignal::GetNlinks(TObject* obj,TString name) const |
941 | { | |
942 | // Provide the number of links to the specified object for the name-spec. slot. | |
943 | // If obj=0 all encountered objects for the specified slot will be counted. | |
944 | // | |
945 | // This procedure involves a slot-index search based on the specified name | |
946 | // at each invokation. This may become slow in case many slots have been | |
947 | // defined and/or when this procedure is invoked many times. | |
948 | // In such cases it is preferable to use indexed addressing in the user code | |
949 | // either directly or via a few invokations of GetSlotIndex(). | |
950 | ||
951 | Int_t j=GetSlotIndex(name); | |
952 | Int_t n=0; | |
953 | if (j>0) n=GetNlinks(obj,j); | |
954 | return n; | |
955 | } | |
956 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 957 | TObject* AliSignal::GetLink(Int_t j,Int_t k) const |
5f25234b | 958 | { |
d0a8ef71 | 959 | // Provide pointer of the object linked to the j-th slot at position k. |
960 | ||
5f25234b | 961 | TObject* obj=0; |
d0a8ef71 | 962 | // Note : In the internal storage matrix slots=columns positions=rows |
963 | if (fLinks) obj=fLinks->GetObject(k,j); | |
5f25234b | 964 | return obj; |
965 | } | |
966 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 967 | TObject* AliSignal::GetLink(TString name,Int_t k) const |
968 | { | |
969 | // Provide pointer of the object linked to the name-spec. slot at position k. | |
970 | // | |
971 | // This procedure involves a slot-index search based on the specified name | |
972 | // at each invokation. This may become slow in case many slots have been | |
973 | // defined and/or when this procedure is invoked many times. | |
974 | // In such cases it is preferable to use indexed addressing in the user code | |
975 | // either directly or via a few invokations of GetSlotIndex(). | |
976 | ||
977 | Int_t j=GetSlotIndex(name); | |
978 | TObject* obj=0; | |
979 | if (j>0) obj=GetLink(j,k); | |
980 | return obj; | |
981 | } | |
982 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 983 | void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k) |
5f25234b | 984 | { |
d0a8ef71 | 985 | // Introduce a link (=pointer) to an object for the j-th slot at position k. |
5f25234b | 986 | // Only the pointer values are stored for (backward) reference, meaning |
987 | // that the objects of which the pointers are stored are NOT owned | |
988 | // by the AliSignal object. | |
989 | // | |
990 | // Notes : | |
d0a8ef71 | 991 | // The first slot is at j=1 and the first position is at k=1. |
992 | // j=1 and k=1 are the default values. | |
5f25234b | 993 | // |
d0a8ef71 | 994 | // If needed, the storage area for the links is increased automatically. |
5f25234b | 995 | // |
996 | // In case the pointer argument is zero, indeed a value of zero will be | |
d0a8ef71 | 997 | // stored at the specified position (k) for the specified slot (j). |
5f25234b | 998 | // |
999 | // In principle any object derived from TObject can be referred to by this | |
1000 | // mechanism. | |
1001 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1002 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1003 | // is related (see AliTrack::AddSignal). | |
1004 | // Therefore, in case the input argument "obj" points to an AliTrack (or derived) | |
1005 | // object, the current signal is automatically related to this AliTrack | |
1006 | // (or derived) object. | |
1007 | // | |
1008 | // Please also have a look at the docs of the memberfunction ResetLink() | |
1009 | // to prevent the situation of stored pointers to non-existent object. | |
1010 | ||
d0a8ef71 | 1011 | if (!fLinks && obj) fLinks=new AliObjMatrix(); |
5f25234b | 1012 | |
d0a8ef71 | 1013 | if (!fLinks) return; |
5f25234b | 1014 | |
d0a8ef71 | 1015 | // Note : In the internal storage matrix slots=columns positions=rows |
1016 | fLinks->EnterObject(k,j,obj); | |
1017 | if (obj) | |
5f25234b | 1018 | { |
d0a8ef71 | 1019 | if (obj->InheritsFrom("AliTrack")) |
5f25234b | 1020 | { |
d0a8ef71 | 1021 | AliTrack* t=(AliTrack*)obj; |
1022 | t->AddSignal(*this); | |
5f25234b | 1023 | } |
1024 | } | |
1025 | } | |
1026 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1027 | void AliSignal::SetLink(TObject* obj,TString name,Int_t k) |
1028 | { | |
1029 | // Introduce a link (=pointer) to an object for the name-spec. slot at position k. | |
1030 | // Only the pointer values are stored for (backward) reference, meaning | |
1031 | // that the objects of which the pointers are stored are NOT owned | |
1032 | // by the AliSignal object. | |
1033 | // | |
1034 | // This procedure involves a slot-index search based on the specified name | |
1035 | // at each invokation. This may become slow in case many slots have been | |
1036 | // defined and/or when this procedure is invoked many times. | |
1037 | // In such cases it is preferable to use indexed addressing in the user code | |
1038 | // either directly or via a few invokations of GetSlotIndex(). | |
1039 | ||
1040 | Int_t j=GetSlotIndex(name); | |
1041 | if (j>0) SetLink(obj,j,k); | |
1042 | } | |
1043 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1044 | void AliSignal::AddLink(TObject* obj,Int_t j) |
1045 | { | |
1046 | // Introduce a link (=pointer) to an object for the j-th slot at the first | |
1047 | // free position. | |
1048 | // Only the pointer values are stored for (backward) reference, meaning | |
1049 | // that the objects of which the pointers are stored are NOT owned | |
1050 | // by the AliSignal object. | |
1051 | // | |
1052 | // Notes : | |
1053 | // The first slot is at j=1 and the first position is at k=1. | |
1054 | // j=1 is the default value. | |
1055 | // | |
1056 | // If needed, the storage area for the links is increased automatically. | |
1057 | // | |
1058 | // In case the pointer argument is zero, no link will be added. | |
1059 | // | |
1060 | // In principle any object derived from TObject can be referred to by this | |
1061 | // mechanism. | |
1062 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1063 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1064 | // is related (see AliTrack::AddSignal). | |
1065 | // Therefore, in case the input argument "obj" points to an AliTrack (or derived) | |
1066 | // object, the current signal is automatically related to this AliTrack | |
1067 | // (or derived) object. | |
1068 | // | |
1069 | // Please also have a look at the docs of the memberfunction ResetLink() | |
1070 | // to prevent the situation of stored pointers to non-existent object. | |
1071 | ||
1072 | if (!obj || j<=0) return; | |
1073 | ||
1074 | if (!fLinks) fLinks=new AliObjMatrix(); | |
1075 | ||
1076 | TObject* dum=0; | |
1077 | Int_t n=GetNlinks(dum,j); | |
1078 | Int_t pos=1; | |
1079 | for (Int_t k=1; k<=n; k++) | |
1080 | { | |
1081 | dum=GetLink(j,k); | |
1082 | if (!dum) break; | |
1083 | pos++; | |
1084 | } | |
1085 | ||
1086 | SetLink(obj,j,pos); | |
1087 | } | |
1088 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1089 | void AliSignal::AddLink(TObject* obj,TString name) |
1090 | { | |
1091 | // Introduce a link (=pointer) to an object for the name-spec slot at the first | |
1092 | // free position. | |
1093 | // Only the pointer values are stored for (backward) reference, meaning | |
1094 | // that the objects of which the pointers are stored are NOT owned | |
1095 | // by the AliSignal object. | |
1096 | // | |
1097 | // This procedure involves a slot-index search based on the specified name | |
1098 | // at each invokation. This may become slow in case many slots have been | |
1099 | // defined and/or when this procedure is invoked many times. | |
1100 | // In such cases it is preferable to use indexed addressing in the user code | |
1101 | // either directly or via a few invokations of GetSlotIndex(). | |
1102 | ||
1103 | Int_t j=GetSlotIndex(name); | |
1104 | if (j>0) AddLink(obj,j); | |
1105 | } | |
1106 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1107 | void AliSignal::ResetLink(Int_t j,Int_t k) |
5f25234b | 1108 | { |
d0a8ef71 | 1109 | // Reset the link of the j-th slot at position k. |
1110 | // | |
1111 | // Notes : | |
1112 | // The first slot is at j=1 and the first position is at k=1. | |
1113 | // j=1 and k=1 are the default values. | |
1114 | // | |
1115 | // This memberfunction is intended to reset only 1 specified link location. | |
1116 | // For extended functionality, please refer to the memberfuction ResetLinks(). | |
5f25234b | 1117 | // |
1118 | // In general the user should take care of properly clearing the corresponding | |
1119 | // pointer here when the referred object is deleted. | |
1120 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1121 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1122 | // is related (see AliTrack::AddSignal). | |
1123 | // As such, the AliTrack destructor already takes care of clearing the corresponding | |
1124 | // links from the various AliSignal slots for all the AliSignal objects that were | |
1125 | // related to that AliTrack. | |
1126 | // So, in case the link introduced via SetLink() is the pointer of an AliTrack object, | |
1127 | // the user doesn't have to worry about clearing the corresponding AliTrack link from | |
1128 | // the AliSignal object when the corresponding AliTrack object is deleted. | |
1129 | ||
d0a8ef71 | 1130 | // Note : In the internal storage matrix slots=columns positions=rows |
1131 | if (fLinks) fLinks->RemoveObject(k,j); | |
5f25234b | 1132 | } |
1133 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1134 | void AliSignal::ResetLink(TString name,Int_t k) |
1135 | { | |
1136 | // Reset the link of the name-specified slot at position k. | |
1137 | // | |
1138 | // This memberfunction is intended to reset only 1 specified link location. | |
1139 | // For extended functionality, please refer to the memberfuction ResetLinks(). | |
1140 | // | |
1141 | // This procedure involves a slot-index search based on the specified name | |
1142 | // at each invokation. This may become slow in case many slots have been | |
1143 | // defined and/or when this procedure is invoked many times. | |
1144 | // In such cases it is preferable to use indexed addressing in the user code | |
1145 | // either directly or via a few invokations of GetSlotIndex(). | |
1146 | ||
1147 | Int_t j=GetSlotIndex(name); | |
1148 | if (j>0) ResetLink(j,k); | |
1149 | } | |
1150 | /////////////////////////////////////////////////////////////////////////// | |
d0a8ef71 | 1151 | void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k) |
5f25234b | 1152 | { |
d0a8ef71 | 1153 | // Reset single or multiple link(s) according to user specified selections. |
1154 | // | |
1155 | // A link is only reset if the stored reference matches the argument "obj". | |
1156 | // In case obj=0 no check on the matching of the stored reference is performed | |
1157 | // and the stored link is always reset in accordance with the other | |
1158 | // selection criteria. | |
1159 | // | |
1160 | // In case the slot argument "j" is specified, only the links from that | |
1161 | // specified slot will be deleted. | |
1162 | // In case j=0 (default) no checking on the slot index is performed. | |
1163 | // | |
1164 | // In case the position argument "k" is specified, only the links from that | |
1165 | // specified position will be deleted. | |
1166 | // In case k=0 (default) no checking on the position index is performed. | |
1167 | // | |
1168 | // So, invokation of ResetLinks(obj) will remove all references to the | |
1169 | // object "obj" from the total AliSignal, whereas ResetLinks(obj,j) | |
1170 | // will remove all references to the object "obj" only from slot "j". | |
1171 | // | |
1172 | // Notes : | |
1173 | // ------- | |
1174 | // The first slot is indicated as j=1, whereas the first position is at k=1. | |
1175 | // | |
1176 | // Invokation of ResetLinks(0,row,col) is equivalent to invoking the | |
1177 | // memberfunction ResetLink(row,col). | |
1178 | // Invoking the latter directly is slightly faster. | |
1179 | // | |
1180 | // Invokation of ResetLinks(0) will reset all stored references in this AliSignal. | |
5f25234b | 1181 | // |
1182 | // In general the user should take care of properly clearing the corresponding | |
1183 | // pointer here when the referred object is deleted. | |
1184 | // However, this "linking back" facility was introduced to enable AliSignal slots | |
1185 | // to refer directly to the various AliTracks to which the AliSignal object itself | |
1186 | // is related (see AliTrack::AddSignal). | |
1187 | // As such, the AliTrack destructor already takes care of clearing the corresponding | |
1188 | // links from the various AliSignal slots for all the AliSignal objects that were | |
1189 | // related to that AliTrack. | |
1190 | // So, in case the link introduced via SetLink() is the pointer of an AliTrack object, | |
1191 | // the user doesn't have to worry about clearing the corresponding AliTrack link from | |
1192 | // the AliSignal object when the corresponding AliTrack object is deleted. | |
1193 | ||
d0a8ef71 | 1194 | if (!fLinks) return; |
5f25234b | 1195 | |
d0a8ef71 | 1196 | if (!obj && !j && !k) |
5f25234b | 1197 | { |
d0a8ef71 | 1198 | fLinks->Reset(); |
5f25234b | 1199 | } |
d0a8ef71 | 1200 | else |
1201 | { | |
1202 | // Note : In the internal storage matrix slots=columns positions=rows | |
1203 | fLinks->RemoveObjects(obj,k,j); | |
1204 | } | |
1205 | } | |
1206 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1207 | void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k) |
1208 | { | |
1209 | // Reset single or multiple link(s) according to user specified selections. | |
1210 | // | |
1211 | // A link is only reset if the stored reference matches the argument "obj". | |
1212 | // In case obj=0 no check on the matching of the stored reference is performed | |
1213 | // and the stored link is always reset in accordance with the other | |
1214 | // selection criteria. | |
1215 | // | |
1216 | // In case the position argument "k" is specified, only the links from that | |
1217 | // specified position will be deleted. | |
1218 | // In case k=0 (default) no checking on the position index is performed. | |
1219 | // | |
1220 | // This procedure involves a slot-index search based on the specified name | |
1221 | // at each invokation. This may become slow in case many slots have been | |
1222 | // defined and/or when this procedure is invoked many times. | |
1223 | // In such cases it is preferable to use indexed addressing in the user code | |
1224 | // either directly or via a few invokations of GetSlotIndex(). | |
1225 | ||
1226 | Int_t j=GetSlotIndex(name); | |
1227 | if (j>0) ResetLinks(obj,j,k); | |
1228 | } | |
1229 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1230 | Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const |
d0a8ef71 | 1231 | { |
1232 | // Provide the slot and position indices of all the storage locations | |
1233 | // of the specified object. | |
1234 | // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays | |
1235 | // from which the (j,k) pairs can be obtained from the corresponding | |
1236 | // array indices like (j,k)=(js.At(i),ks.At(i)). | |
1237 | // The integer return argument represents the number of (j,k) pairs which | |
1238 | // were encountered for the specified object. | |
1239 | // | |
1240 | // If obj=0 no object selection is performed and all (j,k) indices | |
1241 | // of the stored references for all objects are returned. | |
1242 | // | |
1243 | // Notes : | |
1244 | // ------- | |
1245 | // As usual the convention is that slot and position numbering starts at 1. | |
1246 | // | |
1247 | // This memberfunction always resets the two TArrayI arrays at the start. | |
1248 | // | |
1249 | // This memberfunction can only be used to obtain the (j,k) indices | |
1250 | // of the object as stored via the SetLink() or AddLink() memberfunction. | |
1251 | // This means that in case the user has entered a TObjArray as object | |
1252 | // (to increase the dimension of the resulting structure), the (j,k) | |
1253 | // indices of that TObjArray are obtained and NOT the indices of the | |
1254 | // actual objects contained in that TObjArray structure. | |
1255 | // | |
1256 | Int_t nrefs=0; | |
1257 | js.Reset(); | |
1258 | ks.Reset(); | |
1259 | // Note : In the internal storage matrix slots=columns positions=rows | |
1260 | if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js); | |
1261 | return nrefs; | |
1262 | } | |
1263 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1264 | Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const |
d0a8ef71 | 1265 | { |
1266 | // Provide the position indices of all the storage locations of the | |
1267 | // specified object in the j-th slot of this AliSignal. | |
1268 | // The position indices are returned in the TArrayI array. | |
1269 | // The integer return argument represents the number of storage locations which | |
1270 | // were encountered for the specified object in the j-th slot. | |
1271 | // | |
1272 | // If obj=0 no object selection is performed and all position indices | |
1273 | // of the stored references for all objects of the j-th slot are returned. | |
1274 | // | |
1275 | // If j=0 all slots will be scanned and all position indices matching the | |
1276 | // object selection are returned. | |
1277 | // Note that in this case multiple appearances of the same position index | |
1278 | // will only be recorded once in the returned TArrayI array. | |
1279 | // | |
1280 | // Notes : | |
1281 | // ------- | |
1282 | // As usual the convention is that slot and position numbering starts at 1. | |
1283 | // | |
1284 | // This memberfunction always resets the TArrayI array at the start. | |
1285 | // | |
1286 | // This memberfunction can only be used to obtain the position indices | |
1287 | // of the object as stored via the SetLink() or AddLink() memberfunction. | |
1288 | // This means that in case the user has entered a TObjArray as object | |
1289 | // (to increase the dimension of the resulting structure), the position | |
1290 | // indices of that TObjArray are obtained and NOT the indices of the | |
1291 | // actual objects contained in that TObjArray structure. | |
1292 | // | |
1293 | Int_t nrefs=0; | |
1294 | ks.Reset(); | |
1295 | // Note : In the internal storage matrix slots=columns positions=rows | |
1296 | if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j); | |
1297 | return nrefs; | |
1298 | } | |
1299 | /////////////////////////////////////////////////////////////////////////// | |
2cb7369d | 1300 | Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const |
1301 | { | |
1302 | // Provide the position indices of all the storage locations of the | |
1303 | // specified object in the name-specified slot of this AliSignal. | |
1304 | // The position indices are returned in the TArrayI array. | |
1305 | // The integer return argument represents the number of storage locations which | |
1306 | // were encountered for the specified object in the j-th slot. | |
1307 | // | |
1308 | // If obj=0 no object selection is performed and all position indices | |
1309 | // of the stored references for all objects of the j-th slot are returned. | |
1310 | // | |
1311 | // This procedure involves a slot-index search based on the specified name | |
1312 | // at each invokation. This may become slow in case many slots have been | |
1313 | // defined and/or when this procedure is invoked many times. | |
1314 | // In such cases it is preferable to use indexed addressing in the user code | |
1315 | // either directly or via a few invokations of GetSlotIndex(). | |
1316 | ||
1317 | Int_t j=GetSlotIndex(name); | |
1318 | Int_t n=0; | |
1319 | if (j>0) n=GetIndices(obj,j,ks); | |
1320 | return n; | |
1321 | } | |
1322 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1323 | Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const |
d0a8ef71 | 1324 | { |
1325 | // Provide the slot indices of all the storage locations of the | |
1326 | // specified object for the k-th position in this AliSignal. | |
1327 | // The slot indices are returned in the TArrayI array. | |
1328 | // The integer return argument represents the number of storage locations which | |
1329 | // were encountered for the specified object in the k-th position. | |
1330 | // | |
1331 | // If obj=0 no object selection is performed and all slot indices | |
1332 | // of the stored references for all objects in the k-th position are returned. | |
1333 | // | |
1334 | // If k=0 all positions will be scanned and all slot indices matching the | |
1335 | // object selection are returned. | |
1336 | // Note that in this case multiple appearances of the same slot index | |
1337 | // will only be recorded once in the returned TArrayI array. | |
1338 | // | |
1339 | // Notes : | |
1340 | // ------- | |
1341 | // As usual the convention is that slot and position numbering starts at 1. | |
1342 | // | |
1343 | // This memberfunction always resets the TArrayI array at the start. | |
1344 | // | |
1345 | // This memberfunction can only be used to obtain the slot indices | |
1346 | // of the object as stored via the SetLink() or AddLink() memberfunction. | |
1347 | // This means that in case the user has entered a TObjArray as object | |
1348 | // (to increase the dimension of the resulting structure), the slot | |
1349 | // indices of that TObjArray are obtained and NOT the indices of the | |
1350 | // actual objects contained in that TObjArray structure. | |
1351 | // | |
1352 | Int_t nrefs=0; | |
1353 | js.Reset(); | |
1354 | // Note : In the internal storage matrix slots=columns positions=rows | |
1355 | if (fLinks) nrefs=fLinks->GetIndices(obj,k,js); | |
1356 | return nrefs; | |
1357 | } | |
1358 | /////////////////////////////////////////////////////////////////////////// | |
1359 | void AliSignal::SetSwapMode(Int_t swap) | |
1360 | { | |
1361 | // Set swapmode flag for the internal link storage. | |
1362 | // In case for the stored links the maximum slot number differs considerably | |
1363 | // from the maximum position number, it might be more efficient | |
1364 | // (w.r.t. memory usage and/or output file size) to internally store the | |
1365 | // link reference matrix with the rows and colums swapped. | |
1366 | // This swapping is only related with the internal storage and as such | |
1367 | // is completely hidden for the user. | |
1368 | // At invokation of this memberfunction the default argument is swap=1. | |
1369 | // | |
1370 | // Note : The swap mode can only be set as long as no links are | |
1371 | // stored in the AliSignal (i.e. a new instance of AliSignal | |
1372 | // or after invokation of the Reset() or ResetLinks() function). | |
1373 | ||
1374 | if (!fLinks) fLinks=new AliObjMatrix(); | |
1375 | fLinks->SetSwapMode(swap); | |
1376 | } | |
1377 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1378 | Int_t AliSignal::GetSwapMode() const |
d0a8ef71 | 1379 | { |
1380 | // Provide swapmode flag of the link storage. | |
1381 | Int_t swap=0; | |
1382 | if (fLinks) swap=fLinks->GetSwapMode(); | |
1383 | return swap; | |
5f25234b | 1384 | } |
1385 | /////////////////////////////////////////////////////////////////////////// | |
965bd237 | 1386 | void AliSignal::SetDevice(TObject* dev) |
1387 | { | |
1388 | // Store the pointer to the device which owns this AliSignal object. | |
1389 | // This memberfunction is meant for internal use in AliDevice. | |
1390 | fDevice=dev; | |
1391 | } | |
1392 | /////////////////////////////////////////////////////////////////////////// | |
1393 | AliDevice* AliSignal::GetDevice() const | |
1394 | { | |
1395 | // Provide the pointer to the device which owns this AliSignal object. | |
1396 | return (AliDevice*)fDevice; | |
1397 | } | |
1398 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1399 | TObject* AliSignal::Clone(const char* name) const |
c72198f1 | 1400 | { |
1c01b4f8 | 1401 | // Make a deep copy of the current object and provide the pointer to the copy. |
c72198f1 | 1402 | // This memberfunction enables automatic creation of new objects of the |
1c01b4f8 | 1403 | // correct type depending on the object type, a feature which may be very useful |
c72198f1 | 1404 | // for containers when adding objects in case the container owns the objects. |
1405 | // This feature allows e.g. AliTrack to store either AliSignal objects or | |
1406 | // objects derived from AliSignal via the AddSignal memberfunction, provided | |
1c01b4f8 | 1407 | // these derived classes also have a proper Clone memberfunction. |
c72198f1 | 1408 | |
1c01b4f8 | 1409 | AliSignal* sig=new AliSignal(*this); |
1410 | if (name) | |
1411 | { | |
1412 | if (strlen(name)) sig->SetName(name); | |
1413 | } | |
c72198f1 | 1414 | return sig; |
1415 | } | |
1416 | /////////////////////////////////////////////////////////////////////////// |