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