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