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