1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Generic handling of (extrapolated) detector signals.
22 // The user can decide to store either calibrated or uncalibrated signals.
23 // Via the specification of a gain and offset or/and an explicit
24 // (de)calibration function both calibrated and uncalibrated signals
25 // can always be obtained. For details see the documentation of the
26 // memberfunction GetSignal() and the class AliAttrib.
27 // The explicit specification of a (de)calibration function offers the
28 // maximum flexibility and also allows automatic indication whether
29 // calibrated or uncalibrated data has been stored.
30 // The latter can be achieved by only specifying a calibration function
31 // (and no de-calibration function) in case uncalibrated data is stored,
32 // whereas in case of stored calibrated data the user should only
33 // provide a de-calibration function (and no calibration function).
37 // Signal positions (r) and reference frames (f) are specified via
38 // SetPosition(r,f) under the following conventions :
40 // f="car" ==> r is Cartesian (x,y,z)
41 // f="sph" ==> r is Spherical (r,theta,phi)
42 // f="cyl" ==> r is Cylindrical (rho,phi,z)
44 // The same holds for SetPositionErrors().
46 // All angles are in radians.
52 // s.SetName("Start counter");
53 // Float_t pos[3]={-1,25,7};
54 // Float_t err[3]={0.03,0.7,0.18};
55 // Float_t signal=120.8;
56 // Float_t error=1.73;
57 // Float_t offset=-12.78;
59 // s.SetPosition(pos,"car");
60 // s.SetPositionErrors(err,"car");
61 // s.SetSignal(signal);
62 // s.SetSignalError(error);
63 // s.SetOffset(offset);
65 // Float_t loc[3],dr[3],sigma;
66 // s.GetPosition(loc,"sph");
67 // s.GetPositionErrors(dr,"sph");
68 // Float_t adc=s.GetSignal();
69 // Float_t sigma=s.GetSignalError();
71 // AliSignal q; // In the example below a signal contains the
72 // // following data : timing, ADC and dE/dx
73 // q.SetNameTitle("Hybrid","Test for multiple signal data");
74 // q.SetPosition(pos,"car");
75 // q.SetPositionErrors(err,"car");
76 // signal=82.5; // e.g. signal time in ns
79 // q.SetSlotName("TOF",1);
80 // q.SetSignal(signal,1);
81 // q.SetSignalError(error,1);
82 // q.SetOffset(offset,1);
83 // signal=268.1; // e.g. ADC value of signal
87 // // Addressing via name specification instead of index
88 // q.SetSlotName("ADC",2);
89 // q.SetSignal(signal,"ADC");
90 // q.SetSignalError(error,"ADC");
91 // q.SetGain(gain,"ADC");
92 // q.SetOffset(offset,"ADC");
93 // signal=23.7; // e.g. corresponding dE/dx value
95 // TF1 f=("calib","[0]*pow(x,2)+[1]"); // dE/dx calib. function
96 // f.SetParameter(0,3.285);
97 // f.SetParameter(1,-18.67);
98 // q.SetSlotName("dE/dx",3);
99 // q.SetCalFunction(&f,"dE/dx");
100 // q.SetSignal(signal,"dE/dx");
101 // q.SetSignalError(error,"dE/dx");
103 // // Signal retrieval with various (de)calibration modes
104 // Float_t tof=q.GetSignal("TOF");
105 // Float_t adc=q.GetSignal("ADC",1);
106 // Float_t dedx=q.GetSignal("dE/dx",3);
108 //--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht
109 //- Modified: NvE $Date$ UU-SAP Utrecht
110 ///////////////////////////////////////////////////////////////////////////
113 #include "AliSignal.h"
114 #include "AliTrack.h"
115 #include "Riostream.h"
117 ClassImp(AliSignal) // Class implementation to enable ROOT I/O
119 AliSignal::AliSignal() : TNamed(),AliPosition(),AliAttrib()
121 // Creation of an AliSignal object and initialisation of parameters.
122 // Several signal values (with errors) can be stored in different slots.
123 // If needed, the storage for values (and errors) will be expanded automatically
124 // when entering values and/or errors.
133 ///////////////////////////////////////////////////////////////////////////
134 AliSignal::~AliSignal()
136 // Destructor to delete dynamically allocated memory
164 // Remove this signal from all related tracks
165 for (Int_t i=1; i<=GetNtracks(); i++)
167 AliTrack* tx=GetTrack(i);
168 if (tx) tx->RemoveSignal(*this,0);
174 ///////////////////////////////////////////////////////////////////////////
175 AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s)
185 // Don't copy the owning device pointer for the copy
188 Int_t n=s.GetNvalues();
191 for (Int_t i=1; i<=n; i++)
193 if (s.GetSignalFlag(i))
196 lock=s.GetLockValue();
204 for (Int_t j=1; j<=n; j++)
206 if (s.GetErrorFlag(j))
208 val=s.GetSignalError(j);
209 lock=s.GetLockValue();
211 SetSignalError(val,j);
217 for (Int_t k=1; k<=n; k++)
219 TH1F* hist=s.GetWaveform(k);
220 if (hist) SetWaveform(hist,k);
226 n=s.GetIndices(dum,slotarr,posarr);
228 for (Int_t idx=0; idx<n; idx++)
230 slot=slotarr.At(idx);
232 TObject* obj=s.GetLink(slot,pos);
233 if (obj) SetLink(obj,slot,pos);
236 Int_t ntk=s.GetNtracks();
239 fTracks=new TObjArray(ntk);
240 for (Int_t it=1; it<=ntk; it++)
242 AliTrack* tx=s.GetTrack(it);
247 ///////////////////////////////////////////////////////////////////////////
248 void AliSignal::Reset(Int_t mode)
250 // Reset all signal and position values and errors to 0.
252 // mode = 0 Reset position and all signal values and their errors to 0.
253 // The waveform histograms are reset, but the calibration
254 // constants (i.e. gains and offsets) are kept.
255 // 1 Reset position and delete the signal and error storage arrays.
256 // Also the waveform histograms, gains and offset arrays are deleted.
258 // The default when invoking Reset() corresponds to mode=0.
260 // Note : In all cases the storage of the various links will be reset.
261 // The UniqueID, name and title will NOT be reset.
262 // In case the user wants to reset these attributes, this has to
263 // be done explicitly via the SET facilities.
265 // The usage of mode=0 allows to re-use the allocated memory for new
266 // signal (and error) values. This behaviour is preferable (i.e. faster)
267 // in case the various signals always contain the same number of values
268 // and have the same calibration constants.
269 // The usage of mode=1 is slower, but allows a more efficient memory
270 // occupation (and smaller output file size) in case the different
271 // signals have a variable number of values.
273 // For more specific actions see ResetPosition(), ResetSignals(),
274 // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(),
275 // DeleteWaveform() and DeleteCalibrations().
278 if (mode<0 || mode>1)
280 cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl;
281 cout << " Default mode=0 will be used." << endl;
293 DeleteCalibrations();
296 if (fLinks) fLinks->Reset();
305 ///////////////////////////////////////////////////////////////////////////
306 void AliSignal::ResetSignals(Int_t mode)
308 // Reset various signal data according to user selection.
310 // mode = 0 Reset all signal values, their errors and all waveform histos.
311 // 1 Reset only signal values and waveform histos.
312 // 2 Reset only signal errors and waveform histos.
313 // -1 Reset only signal values.
314 // -2 Reset only signal errors.
316 // The default when invoking ResetSignals() corresponds to mode=0.
320 cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl;
321 cout << " Default mode=0 will be used." << endl;
328 if (fSignals && (abs(mode)==0 || abs(mode)==1))
330 for (Int_t i=1; i<=fSignals->GetSize(); i++)
332 fSignals->AddAt(0,i-1);
333 eflag=GetErrorFlag(i);
334 SetSigFlags(0,eflag,i);
338 if (fDsignals && (abs(mode)==0 || abs(mode)==2))
340 for (Int_t j=1; j<=fDsignals->GetSize(); j++)
342 fDsignals->AddAt(0,j-1);
343 sflag=GetSignalFlag(j);
344 SetSigFlags(sflag,0,j);
348 if (mode>=0) ResetWaveform(0);
350 ///////////////////////////////////////////////////////////////////////////
351 void AliSignal::DeleteSignals(Int_t mode)
353 // Delete storage arrays of various signal data according to user selection.
355 // mode = 0 Delete arrays of signal values, their errors and all waveform histos.
356 // 1 Delete only signal values array and waveform histos.
357 // 2 Delete only signal errors array and waveform histos.
358 // -1 Delete only signal values array.
359 // -2 Delete only signal errors array.
361 // The default when invoking DeleteSignals() corresponds to mode=0.
365 cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl;
366 cout << " Default mode=0 will be used." << endl;
370 if (fSignals && (abs(mode)==0 || abs(mode)==1))
376 if (fDsignals && (abs(mode)==0 || abs(mode)==2))
390 else if (abs(mode)==1)
392 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
394 eflag=GetErrorFlag(i);
395 SetSigFlags(0,eflag,i);
398 else if (abs(mode)==2)
400 for (Int_t j=1; j<=fSigflags->GetSize(); j++)
402 sflag=GetSignalFlag(j);
403 SetSigFlags(sflag,0,j);
407 if (mode>=0) DeleteWaveform(0);
409 ///////////////////////////////////////////////////////////////////////////
410 void AliSignal::SetSignal(Double_t sig,Int_t j)
412 // Store signal value for the j-th (default j=1) slot.
415 // 1) The first signal slot is at j=1.
416 // 2) In case the 'lock' flag was set for the specified slot, the new
417 // signal value will not be stored.
418 // One has to unlock the specified slot first in case one really wants
419 // to overwite the signal value.
420 // In case the value of the index j exceeds the maximum number of reserved
421 // slots for signal values, the number of reserved slots for the
422 // signal values is increased automatically.
424 if (GetLockValue(j)) return;
428 fSignals=new TArrayF(j);
432 Int_t size=fSignals->GetSize();
439 fSignals->AddAt(float(sig),j-1);
441 Int_t eflag=GetErrorFlag(j);
442 SetSigFlags(1,eflag,j);
444 ///////////////////////////////////////////////////////////////////////////
445 void AliSignal::SetSignal(Double_t sig,TString name)
447 // Store signal value for the name-specified slot.
451 // In case the 'lock' flag was set for the specified slot, the new
452 // signal value will not be stored.
453 // One has to unlock the specified slot first in case one really wants
454 // to overwite the signal value.
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().
462 Int_t j=GetSlotIndex(name);
465 if (!GetLockValue(j)) SetSignal(sig,j);
468 ///////////////////////////////////////////////////////////////////////////
469 void AliSignal::AddSignal(Double_t sig,Int_t j)
471 // Add value to the signal of the j-th (default j=1) slot.
474 // 1) The first signal slot is at j=1.
475 // 2) In case the 'lock' flag was set for the specified slot, the new
476 // signal value will not be stored.
477 // One has to unlock the specified slot first in case one really wants
478 // to overwite the signal value.
479 // In case the value of the index j exceeds the maximum number of reserved
480 // slots for signal values, the number of reserved slots for the
481 // signal values is increased automatically.
483 if (GetLockValue(j)) return;
487 fSignals=new TArrayF(j);
491 Int_t size=fSignals->GetSize();
498 Float_t sum=(fSignals->At(j-1))+sig;
499 fSignals->AddAt(sum,j-1);
501 Int_t eflag=GetErrorFlag(j);
502 SetSigFlags(1,eflag,j);
504 ///////////////////////////////////////////////////////////////////////////
505 void AliSignal::AddSignal(Double_t sig,TString name)
507 // Add value to the signal of the name-specified slot.
511 // In case the 'lock' flag was set for the specified slot, the new
512 // signal value will not be stored.
513 // One has to unlock the specified slot first in case one really wants
514 // to overwite the signal value.
516 // This procedure involves a slot-index search based on the specified name
517 // at each invokation. This may become slow in case many slots have been
518 // defined and/or when this procedure is invoked many times.
519 // In such cases it is preferable to use indexed addressing in the user code
520 // either directly or via a few invokations of GetSlotIndex().
522 Int_t j=GetSlotIndex(name);
525 if (!GetLockValue(j)) AddSignal(sig,j);
528 ///////////////////////////////////////////////////////////////////////////
529 Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const
531 // Provide signal value of the j-th (default j=1) slot.
532 // Note : The first signal slot is at j=1.
533 // In case no signal is present or the input argument "j" or "mode" is invalid,
534 // the value 0 is returned.
535 // The parameter "mode" allows for automatic (de)calibration of the signal
536 // (e.g. gain etc... correction or via explicit (de)calibration functions).
538 // mode = 0 : Just the j-th signal is returned.
539 // 1 : The j-th signal is corrected for the gain, offset, dead flag etc...
540 // In case the j-th slot was marked dead, 0 is returned.
541 // In case the gain value was not set, gain=1 will be assumed.
542 // In case the gain value was 0, a signal value of 0 is returned.
543 // In case the offset value was not set, offset=0 will be assumed.
544 // 2 : Same as mode=1 but gain, offset dead flag etc... are taken from
545 // the AliDevice which owns this AliSignal object.
546 // The corresponding AliDevice slot is obtained via matching of
547 // the slotnames. In case this fails, the slotindex "j" of the
548 // input argument will be used.
549 // In case this AliSignal object has no parent AliDevice, just
550 // the j-th signal is returned (like with mode=0).
551 // 3 : The j-th signal is corrected using the corresponding calibration
553 // In case the j-th slot was marked dead, 0 is returned.
554 // In case no calibration function is present, just the j-th signal
555 // is returned (like with mode=0).
556 // 4 : Same as mode=3 but the calibration function and dead flag are
557 // taken from the AliDevice which owns this AliSignal object.
558 // The corresponding AliDevice slot is obtained via matching of
559 // the slotnames. In case this fails, the slotindex "j" of the
560 // input argument will be used.
561 // 5 : Same as mode=2 but in case no parent AliDevice is present
562 // an automatic switch to mode=1 will be made.
563 // 6 : Same as mode=4 but in case no parent AliDevice is present
564 // an automatic switch to mode=3 will be made.
565 // 7 : Same as mode=3 but in case no calibration function is present
566 // an automatic switch to mode=4 will be made.
567 // 8 : Same as mode=7 but also the corresponding dead flag of the
568 // parent device (if any) will be checked.
569 // If either the dead flag of the requested signal slot of this
570 // AliSignal object or the corresponding parent device slot is
571 // set, 0 is returned.
573 // <0 : The corresponding de-correction or de-calibration is performed
575 // The corrected signal (sigc) is determined as follows :
577 // sigc=(signal/gain)-offset
579 // The de-corrected signal is determined as follows :
581 // signal=(sigc+offset)*gain
583 // The default is mode=0.
585 if (abs(mode)>8) return 0;
592 // Get the corresponding slot index (and dead flag) of the parent device
595 AliSignal* parent=(AliSignal*)GetDevice();
596 if ((abs(mode)==2 || abs(mode)>=4) && parent)
598 TString name=GetSlotName(j);
599 if (strlen(name.Data())) pj=parent->GetSlotIndex(name);
600 if (abs(mode)==8 && pj) pdead=parent->GetDeadValue(pj);
603 if (mode==-8) mode=-7;
605 AliSignal* sx=(AliSignal*)this;
610 f=sx->GetCalFunction(jcal);
622 f=sx->GetDecalFunction(jcal);
633 if (abs(mode)==2 || abs(mode)>=4)
635 sx=(AliSignal*)GetDevice();
638 if (!sx && abs(mode)>=5) sx=(AliSignal*)this;
640 if (mode==-5) mode=-2;
642 if (mode==-6) mode=-3;
646 if (j>0 && j<=(fSignals->GetSize()))
648 sig=fSignals->At(j-1);
650 if (mode==0 || !sx) return sig;
652 // Check for the dead flag setting
653 if (sx->GetDeadValue(jcal) || pdead) return 0;
655 // (De)correct the signal for the gain and offset
656 if (abs(mode)==1 || abs(mode)==2)
658 if (sx->GetGainFlag(jcal)) gain=sx->GetGain(jcal);
659 if (sx->GetOffsetFlag(jcal)) offset=sx->GetOffset(jcal);
663 if (mode>0) sig=(sig/gain)-offset; // Gain and offset correction
664 if (mode<0) sig=(sig+offset)*gain; // Gain and offset de-correction
673 // (De)calibrate the signal with the corresponding (de)calibration function
674 if (abs(mode)==3 || abs(mode)==4)
676 f=sx->GetCalFunction(jcal);
677 if (mode<0) f=sx->GetDecalFunction(jcal);
678 if (f) sig=f->Eval(sig);
684 cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl;
689 ///////////////////////////////////////////////////////////////////////////
690 Float_t AliSignal::GetSignal(TString name,Int_t mode) const
692 // Provide signal value of the name-specified slot.
693 // In case no signal is present, 0 is returned.
694 // The parameter "mode" allows for automatic (de)calibration of the signal
695 // (e.g. gain etc... correction or via explicit (de)calibration functions).
696 // For further details about the (de)calibration modes, please refer to the
697 // corresponding slot-index based memberfunction.
699 // The default is mode=0.
701 // This procedure involves a slot-index search based on the specified name
702 // at each invokation. This may become slow in case many slots have been
703 // defined and/or when this procedure is invoked many times.
704 // In such cases it is preferable to use indexed addressing in the user code
705 // either directly or via a few invokations of GetSlotIndex().
707 Int_t j=GetSlotIndex(name);
709 if (j>0) val=GetSignal(j,mode);
712 ///////////////////////////////////////////////////////////////////////////
713 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
715 // Store error on the signal for the j-th (default j=1) slot.
718 // 1) The first signal slot is at j=1.
719 // 2) In case the 'lock' flag was set for the specified slot, the new
720 // signal error value will not be stored.
721 // One has to unlock the specified slot first in case one really wants
722 // to overwite the signal error value.
723 // In case the value of the index j exceeds the maximum number of reserved
724 // slots for signal error values, the number of reserved slots for the
725 // signal errors is increased automatically.
727 if (GetLockValue(j)) return;
731 fDsignals=new TArrayF(j);
735 Int_t size=fDsignals->GetSize();
742 fDsignals->AddAt(float(dsig),j-1);
744 Int_t sflag=GetSignalFlag(j);
745 SetSigFlags(sflag,1,j);
747 ///////////////////////////////////////////////////////////////////////////
748 void AliSignal::SetSignalError(Double_t dsig,TString name)
750 // Store error on the signal for the name-specified slot.
754 // In case the 'lock' flag was set for the specified slot, the new
755 // signal error value will not be stored.
756 // One has to unlock the specified slot first in case one really wants
757 // to overwite the signal error value.
759 // This procedure involves a slot-index search based on the specified name
760 // at each invokation. This may become slow in case many slots have been
761 // defined and/or when this procedure is invoked many times.
762 // In such cases it is preferable to use indexed addressing in the user code
763 // either directly or via a few invokations of GetSlotIndex().
765 Int_t j=GetSlotIndex(name);
768 if (!GetLockValue(j)) SetSignalError(dsig,j);
771 ///////////////////////////////////////////////////////////////////////////
772 Float_t AliSignal::GetSignalError(Int_t j) const
774 // Provide error on the signal of the j-th (default j=1) slot.
775 // Note : The first signal slot is at j=1.
776 // In case no signal is present or the argument j is invalid, 0 is returned.
780 if (j>0 && j<=(fDsignals->GetSize()))
782 err=fDsignals->At(j-1);
786 cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl;
791 ///////////////////////////////////////////////////////////////////////////
792 Float_t AliSignal::GetSignalError(TString name) const
794 // Provide error on the signal of the name-specified slot.
796 // This procedure involves a slot-index search based on the specified name
797 // at each invokation. This may become slow in case many slots have been
798 // defined and/or when this procedure is invoked many times.
799 // In such cases it is preferable to use indexed addressing in the user code
800 // either directly or via a few invokations of GetSlotIndex().
802 Int_t j=GetSlotIndex(name);
804 if (j>0) val=GetSignalError(j);
807 ///////////////////////////////////////////////////////////////////////////
808 void AliSignal::Data(TString f,TString u) const
810 // Provide all signal information within the coordinate frame f.
812 // The string argument "u" allows to choose between different angular units
813 // in case e.g. a spherical frame is selected.
814 // u = "rad" : angles provided in radians
815 // "deg" : angles provided in degrees
817 // The defaults are f="car" and u="rad".
819 const char* name=GetName();
820 const char* title=GetTitle();
822 cout << " *" << ClassName() << "::Data* Id : " << GetUniqueID();
823 if (strlen(name)) cout << " Name : " << name;
824 if (strlen(title)) cout << " Title : " << title;
827 AliPosition::Data(f,u);
830 const char* devname=fDevice->GetName();
831 const char* devtitle=fDevice->GetTitle();
832 cout << " Owned by device : " << fDevice->ClassName()
833 << " Id : " << fDevice->GetUniqueID();
834 if (strlen(devname)) cout << " Name : " << devname;
835 if (strlen(devtitle)) cout << " Title : " << devtitle;
839 // Provide an overview of the stored waveforms
842 // Provide an overview of the associated tracks
845 // Provide an overview of all the data and attribute slots
848 ///////////////////////////////////////////////////////////////////////////
849 void AliSignal::List(Int_t j) const
851 // Provide signal information for the j-th slot.
852 // The first slot is at j=1.
853 // In case j=0 (default) the data of all slots will be listed.
854 // In case j=-1 the data of all slots will be listed, but the header
855 // information will be suppressed.
859 cout << " *AliSignal::List* Invalid argument j = " << j << endl;
865 const char* name=GetName();
866 const char* title=GetTitle();
868 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
869 if (strlen(name)) cout << " Name : " << name;
870 if (strlen(title)) cout << " Title : " << title;
874 const char* devname=fDevice->GetName();
875 const char* devtitle=fDevice->GetTitle();
876 cout << " Owned by device : " << fDevice->ClassName();
877 if (strlen(devname)) cout << " Name : " << devname;
878 if (strlen(devtitle)) cout << " Title : " << devtitle;
885 if (GetNlinks()) nlinkslots=fLinks->GetMaxColumn();
886 if (nlinkslots>n) n=nlinkslots;
895 for (Int_t i=1; i<=n; i++)
898 nrefs=GetIndices(obj,i,posarr);
900 if (GetSignalFlag(i) || GetErrorFlag(i) || GetCalFunction(i) || GetDecalFunction(i) || GetCalWord(i) || nrefs)
902 cout << " Slot : " << i;
903 if (GetSignalFlag(i)) cout << " Signal value : " << GetSignal(i);
904 if (GetErrorFlag(i)) cout << " error : " << GetSignalError(i);
908 for (Int_t k=0; k<nrefs; k++)
914 cout << " Link at position " << pos << " to : " << obj->ClassName();
915 if (obj->InheritsFrom("TNamed"))
917 const char* lname=obj->GetName();
918 const char* ltitle=obj->GetTitle();
919 if (strlen(lname)) cout << " Name : " << lname;
920 if (strlen(ltitle)) cout << " Title : " << ltitle;
933 nrefs=GetIndices(obj,j,posarr);
935 if (GetSignalFlag(j) || GetErrorFlag(j) || GetCalFunction(j) || GetDecalFunction(j) || GetCalWord(j) || nrefs)
937 cout << " Slot : " << j;
938 if (GetSignalFlag(j)) cout << " Signal value : " << GetSignal(j);
939 if (GetErrorFlag(j)) cout << " error : " << GetSignalError(j);
943 for (Int_t kj=0; kj<nrefs; kj++)
949 cout << " Link at position " << pos << " to : " << obj->ClassName();
950 if (obj->InheritsFrom("TNamed"))
952 const char* lnamej=obj->GetName();
953 const char* ltitlej=obj->GetTitle();
954 if (strlen(lnamej)) cout << " Name : " << lnamej;
955 if (strlen(ltitlej)) cout << " Title : " << ltitlej;
964 ///////////////////////////////////////////////////////////////////////////
965 void AliSignal::List(TString name) const
967 // Provide signal information for the name-specified slot.
969 // This procedure involves a slot-index search based on the specified name
970 // at each invokation. This may become slow in case many slots have been
971 // defined and/or when this procedure is invoked many times.
972 // In such cases it is preferable to use indexed addressing in the user code
973 // either directly or via a few invokations of GetSlotIndex().
975 Int_t j=GetSlotIndex(name);
978 ///////////////////////////////////////////////////////////////////////////
979 void AliSignal::ListWaveform(Int_t j) const
981 // Provide information for the j-th waveform.
982 // The first waveform is at j=1.
983 // In case j=0 (default) the info of all waveforms will be listed.
984 // In case j=-1 the info of all waveforms will be listed, but the header
985 // information will be suppressed.
989 cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl;
995 const char* name=GetName();
996 const char* title=GetTitle();
998 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
999 if (strlen(name)) cout << " Name : " << name;
1000 if (strlen(title)) cout << " Title : " << title;
1004 const char* devname=fDevice->GetName();
1005 const char* devtitle=fDevice->GetTitle();
1006 cout << " Owned by device : " << fDevice->ClassName();
1007 if (strlen(devname)) cout << " Name : " << devname;
1008 if (strlen(devtitle)) cout << " Title : " << devtitle;
1013 Int_t n=GetNwaveforms();
1018 for (Int_t i=1; i<=n; i++)
1023 const char* wfname=obj->GetName();
1024 const char* wftitle=obj->GetTitle();
1025 cout << " Waveform " << i << " : " << obj->ClassName();
1026 if (strlen(wfname)) cout << " Name : " << wfname;
1027 if (strlen(wftitle)) cout << " Title : " << wftitle;
1039 const char* wfnamej=obj->GetName();
1040 const char* wftitlej=obj->GetTitle();
1041 cout << " Waveform " << j << " : " << obj->ClassName();
1042 if (strlen(wfnamej)) cout << " Name : " << wfnamej;
1043 if (strlen(wftitlej)) cout << " Title : " << wftitlej;
1049 ///////////////////////////////////////////////////////////////////////////
1050 void AliSignal::ListTrack(Int_t j) const
1052 // Provide information for the j-th associated track.
1053 // The first associated track is at j=1.
1054 // In case j=0 (default) the info of all associated tracks will be listed.
1055 // In case j=-1 the info of all tracks will be listed, but the header
1056 // information will be suppressed.
1060 cout << " *AliSignal::ListTrack* Invalid argument j = " << j << endl;
1066 const char* name=GetName();
1067 const char* title=GetTitle();
1069 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
1070 if (strlen(name)) cout << " Name : " << name;
1071 if (strlen(title)) cout << " Title : " << title;
1075 const char* devname=fDevice->GetName();
1076 const char* devtitle=fDevice->GetTitle();
1077 cout << " Owned by device : " << fDevice->ClassName();
1078 if (strlen(devname)) cout << " Name : " << devname;
1079 if (strlen(devtitle)) cout << " Title : " << devtitle;
1084 Int_t n=GetNtracks();
1089 for (Int_t i=1; i<=n; i++)
1094 const char* txname=tx->GetName();
1095 const char* txtitle=tx->GetTitle();
1096 cout << " Track " << i << " : " << tx->ClassName() << " Id : " << tx->GetId();
1097 if (strlen(txname)) cout << " Name : " << txname;
1098 if (strlen(txtitle)) cout << " Title : " << txtitle;
1110 const char* txnamej=tx->GetName();
1111 const char* txtitlej=tx->GetTitle();
1112 cout << " Track " << j << " : " << tx->ClassName() << " Id : " << tx->GetId();
1113 if (strlen(txnamej)) cout << " Name : " << txnamej;
1114 if (strlen(txtitlej)) cout << " Title : " << txtitlej;
1120 ///////////////////////////////////////////////////////////////////////////
1121 Int_t AliSignal::GetNvalues() const
1123 // Provide the number of values for this signal.
1125 if (!fSignals) return 0;
1128 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
1130 if (GetSignalFlag(i)) n=i;
1135 ///////////////////////////////////////////////////////////////////////////
1136 Int_t AliSignal::GetNerrors() const
1138 // Provide the number specified errors on the values for this signal.
1140 if (!fDsignals) return 0;
1143 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
1145 if (GetErrorFlag(i)) n=i;
1150 ///////////////////////////////////////////////////////////////////////////
1151 void AliSignal::SetSigFlags(Int_t is,Int_t ie,Int_t j)
1153 // Store signal and/or error value flags of the j-th (default j=1) slot.
1154 // Note : The first slot is at j=1.
1155 // In case the value of the index j exceeds the maximum number of reserved
1156 // slots for the flags, the number of reserved slots for the flags is
1157 // increased automatically.
1158 // The value stored is : 10*signalflag + errorflag.
1162 cout << " *AliSignal::SetSigFlags* Invalid argument j = " << j << endl;
1168 fSigflags=new TArrayI(j);
1171 Int_t size=fSigflags->GetSize();
1178 Int_t word=10*is+ie;
1180 fSigflags->AddAt(word,j-1);
1182 ///////////////////////////////////////////////////////////////////////////
1183 Int_t AliSignal::GetSignalFlag(Int_t j) const
1185 // Provide signal value flag of the j-th (default j=1) slot.
1187 // flag = 1 : Signal value was set
1188 // 0 : Signal value was not set
1190 // Note : The first attribute slot is at j=1.
1191 // In case j is invalid, 0 is returned.
1195 cout << " *AliSignal::GetSignalFlag* Invalid argument j = " << j << endl;
1201 if (j>0 && j<=(fSigflags->GetSize()))
1203 Int_t word=fSigflags->At(j-1);
1209 ///////////////////////////////////////////////////////////////////////////
1210 Int_t AliSignal::GetSignalFlag(TString name) const
1212 // Provide signal value flag of the name-specified slot.
1214 // flag = 1 : Signal value was set
1215 // 0 : Signal value was not set
1218 // This procedure involves a slot-index search based on the specified name
1219 // at each invokation. This may become slow in case many slots have been
1220 // defined and/or when this procedure is invoked many times.
1221 // In such cases it is preferable to use indexed addressing in the user code
1222 // either directly or via a few invokations of GetSlotIndex().
1224 Int_t j=GetSlotIndex(name);
1226 if (j>0) flag=GetSignalFlag(j);
1229 ///////////////////////////////////////////////////////////////////////////
1230 Int_t AliSignal::GetErrorFlag(Int_t j) const
1232 // Provide error value flag of the j-th (default j=1) slot.
1234 // flag = 1 : Error value was set
1235 // 0 : Error value was not set
1237 // Note : The first attribute slot is at j=1.
1238 // In case j is invalid, 0 is returned.
1242 cout << " *AliSignal::GetErrorFlag* Invalid argument j = " << j << endl;
1248 if (j>0 && j<=(fSigflags->GetSize()))
1250 Int_t word=fSigflags->At(j-1);
1256 ///////////////////////////////////////////////////////////////////////////
1257 Int_t AliSignal::GetErrorFlag(TString name) const
1259 // Provide error value flag of the name-specified slot.
1261 // flag = 1 : Error value was set
1262 // 0 : Error value was not set
1265 // This procedure involves a slot-index search based on the specified name
1266 // at each invokation. This may become slow in case many slots have been
1267 // defined and/or when this procedure is invoked many times.
1268 // In such cases it is preferable to use indexed addressing in the user code
1269 // either directly or via a few invokations of GetSlotIndex().
1271 Int_t j=GetSlotIndex(name);
1273 if (j>0) flag=GetErrorFlag(j);
1276 ///////////////////////////////////////////////////////////////////////////
1277 Int_t AliSignal::GetNslots() const
1279 // Provide the number of existing slots.
1281 Int_t n=AliAttrib::GetNslots();
1283 if (!fSigflags) return n;
1286 for (Int_t i=0; i<fSigflags->GetSize(); i++)
1288 if (fSigflags->At(i)) nflags=i+1;
1291 if (n<nflags) n=nflags;
1295 ///////////////////////////////////////////////////////////////////////////
1296 Int_t AliSignal::GetNwaveforms() const
1298 // Provide the number of specified waveforms for this signal.
1299 // Actually the return value is the highest index of the stored waveforms.
1300 // This allows an index dependent meaning of waveform info (e.g. waveforms
1301 // with various gain values).
1302 // So, when all waveforms are stored in consequetive positions (e.g. 1,2,3),
1303 // this memberfunction returns 3, being both the highest filled position
1304 // and the actual number of waveforms.
1305 // In case only waveforms are stored at positions 1,2,5,7 this memberfunction
1306 // returns a value 7 whereas only 4 actual waveforms are present.
1307 // This implies that when looping over the various waveform slots, one
1308 // always has to check whether the returned pointer value is non-zero
1309 // (which is a good practice anyhow).
1311 if (fWaveforms) n=fWaveforms->GetLast();
1314 ///////////////////////////////////////////////////////////////////////////
1315 TH1F* AliSignal::GetWaveform(Int_t j) const
1317 // Provide pointer to the j-th waveform histogram.
1319 if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1);
1322 ///////////////////////////////////////////////////////////////////////////
1323 TH1F* AliSignal::GetWaveform(TString name) const
1325 // Provide pointer to the waveform histogram with the specified name.
1326 // In case no match is found, zero is returned.
1327 Int_t n=GetNwaveforms();
1329 for (Int_t i=1; i<=n; i++)
1331 TH1F* waveform=GetWaveform(i);
1334 str=waveform->GetName();
1335 if (str == name) return waveform;
1338 return 0; // No match found
1340 ///////////////////////////////////////////////////////////////////////////
1341 Int_t AliSignal::GetWaveformIndex(TString name) const
1343 // Provide index to the waveform histogram with the specified name.
1344 // In case no match is found, zero is returned.
1345 Int_t n=GetNwaveforms();
1347 for (Int_t i=1; i<=n; i++)
1349 TH1F* waveform=GetWaveform(i);
1352 str=waveform->GetName();
1353 if (str == name) return i;
1356 return 0; // No match found
1358 ///////////////////////////////////////////////////////////////////////////
1359 void AliSignal::SetWaveform(TH1F* waveform,Int_t j)
1361 // Set the 1D waveform histogram for the j-th waveform.
1364 // The first waveform position at j=1.
1365 // j=1 is the default value.
1367 // In case the value of the index j exceeds the maximum number of reserved
1368 // positions for the waveforms, the number of reserved positions for the waveforms
1369 // is increased automatically.
1371 // In case the histo pointer argument has the same value as the current waveform
1372 // histogram pointer value, no action is taken since the user has already
1373 // modified the actual histogram.
1375 // In case the histo pointer argument is zero, the current waveform histogram
1376 // is deleted and the pointer set to zero.
1378 // In all other cases the current waveform histogram is deleted and a new
1379 // copy of the input histogram is created which becomes the current waveform
1386 fWaveforms=new TObjArray(j);
1387 fWaveforms->SetOwner();
1390 if (j > fWaveforms->GetSize()) fWaveforms->Expand(j);
1392 TH1F* hcur=(TH1F*)fWaveforms->At(j-1);
1393 if (waveform != hcur)
1397 fWaveforms->Remove(hcur);
1403 hcur=new TH1F(*waveform);
1404 fWaveforms->AddAt(hcur,j-1);
1408 ///////////////////////////////////////////////////////////////////////////
1409 void AliSignal::ResetWaveform(Int_t j)
1411 // Reset the histogram of the j-th (default j=1) waveform.
1412 // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s).
1413 // To actually delete the histograms from memory, use DeleteWaveform().
1414 // Notes : The first position is at j=1.
1415 // j=0 ==> All waveforms will be reset.
1417 if (!fWaveforms) return;
1419 Int_t size=fWaveforms->GetSize();
1421 if ((j>=0) && (j<=size))
1425 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1426 if (hwave) hwave->Reset();
1430 for (Int_t i=0; i<size; i++)
1432 TH1F* hwave=(TH1F*)fWaveforms->At(i);
1433 if (hwave) hwave->Reset();
1439 cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl;
1443 ///////////////////////////////////////////////////////////////////////////
1444 void AliSignal::ResetWaveform(TString name)
1446 // Reset the waveform with the specified name.
1447 Int_t j=GetWaveformIndex(name);
1448 if (j>0) ResetWaveform(j);
1450 ///////////////////////////////////////////////////////////////////////////
1451 void AliSignal::DeleteWaveform(Int_t j)
1453 // Delete the histogram of the j-th (default j=1) waveform.
1454 // Notes : The first position is at j=1.
1455 // j=0 ==> All waveforms will be deleted.
1457 if (!fWaveforms) return;
1459 Int_t size=fWaveforms->GetSize();
1461 if ((j>=0) && (j<=size))
1465 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1468 fWaveforms->Remove(hwave);
1480 cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl;
1484 ///////////////////////////////////////////////////////////////////////////
1485 void AliSignal::DeleteWaveform(TString name)
1487 // Delete the waveform with the specified name.
1488 Int_t j=GetWaveformIndex(name);
1489 if (j>0) DeleteWaveform(j);
1491 ///////////////////////////////////////////////////////////////////////////
1492 Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const
1494 // Provide the number of links to the specified object for the j-th slot.
1495 // If j=0 (default) all slots will be scanned for the specified object.
1496 // If obj=0 (default) all encountered objects for the specified slot will be counted.
1497 // So, invokation of the default GetNlinks() will return the total number of
1498 // all references to all sorts of stored objects.
1501 cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl;
1505 if (!fLinks) return 0;
1510 n=fLinks->GetNrefs(obj);
1515 n=GetIndices(obj,j,posarr);
1519 ///////////////////////////////////////////////////////////////////////////
1520 Int_t AliSignal::GetNlinks(TObject* obj,TString name) const
1522 // Provide the number of links to the specified object for the name-spec. slot.
1523 // If obj=0 all encountered objects for the specified slot will be counted.
1525 // This procedure involves a slot-index search based on the specified name
1526 // at each invokation. This may become slow in case many slots have been
1527 // defined and/or when this procedure is invoked many times.
1528 // In such cases it is preferable to use indexed addressing in the user code
1529 // either directly or via a few invokations of GetSlotIndex().
1531 Int_t j=GetSlotIndex(name);
1533 if (j>0) n=GetNlinks(obj,j);
1536 ///////////////////////////////////////////////////////////////////////////
1537 TObject* AliSignal::GetLink(Int_t j,Int_t k) const
1539 // Provide pointer of the object linked to the j-th slot at position k.
1542 // Note : In the internal storage matrix slots=columns positions=rows
1543 if (fLinks) obj=fLinks->GetObject(k,j);
1546 ///////////////////////////////////////////////////////////////////////////
1547 TObject* AliSignal::GetLink(TString name,Int_t k) const
1549 // Provide pointer of the object linked to the name-spec. slot at position k.
1551 // This procedure involves a slot-index search based on the specified name
1552 // at each invokation. This may become slow in case many slots have been
1553 // defined and/or when this procedure is invoked many times.
1554 // In such cases it is preferable to use indexed addressing in the user code
1555 // either directly or via a few invokations of GetSlotIndex().
1557 Int_t j=GetSlotIndex(name);
1559 if (j>0) obj=GetLink(j,k);
1562 ///////////////////////////////////////////////////////////////////////////
1563 void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k)
1565 // Introduce a link (=pointer) to an object for the j-th slot at position k.
1566 // Only the pointer values are stored for (backward) reference, meaning
1567 // that the objects of which the pointers are stored are NOT owned
1568 // by the AliSignal object.
1571 // The first slot is at j=1 and the first position is at k=1.
1572 // j=1 and k=1 are the default values.
1574 // If needed, the storage area for the links is increased automatically.
1576 // In case the pointer argument is zero, indeed a value of zero will be
1577 // stored at the specified position (k) for the specified slot (j).
1579 // In principle any object derived from TObject can be referred to by this
1581 // However, this "linking back" facility was introduced to enable AliSignal slots
1582 // to refer directly to the various AliTracks to which the AliSignal object itself
1583 // is related (see AliTrack::AddSignal).
1584 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1585 // object, the current signal is automatically related to this AliTrack
1586 // (or derived) object.
1587 // Also a global link to this AliTrack (or derived) object will be stored
1588 // via the AddTrack() facility.
1592 // In case one just wants to relate the current AliSignal to a certain AliTrack
1593 // without a specific signal slot association, it is much more efficient
1594 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1596 // Please also have a look at the docs of the memberfunction ResetLink()
1597 // to prevent the situation of stored pointers to non-existent object.
1599 if (!fLinks && obj) fLinks=new AliObjMatrix();
1601 if (!fLinks) return;
1603 // Note : In the internal storage matrix slots=columns positions=rows
1604 fLinks->EnterObject(k,j,obj);
1607 if (obj->InheritsFrom("AliTrack"))
1609 AliTrack* t=(AliTrack*)obj;
1614 ///////////////////////////////////////////////////////////////////////////
1615 void AliSignal::SetLink(TObject* obj,TString name,Int_t k)
1617 // Introduce a link (=pointer) to an object for the name-spec. slot at position k.
1618 // Only the pointer values are stored for (backward) reference, meaning
1619 // that the objects of which the pointers are stored are NOT owned
1620 // by the AliSignal object.
1622 // This procedure involves a slot-index search based on the specified name
1623 // at each invokation. This may become slow in case many slots have been
1624 // defined and/or when this procedure is invoked many times.
1625 // In such cases it is preferable to use indexed addressing in the user code
1626 // either directly or via a few invokations of GetSlotIndex().
1628 // In case the pointer argument is zero, indeed a value of zero will be
1629 // stored at the specified position (k) for the specified slotname.
1631 // In principle any object derived from TObject can be referred to by this
1633 // However, this "linking back" facility was introduced to enable AliSignal slots
1634 // to refer directly to the various AliTracks to which the AliSignal object itself
1635 // is related (see AliTrack::AddSignal).
1636 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1637 // object, the current signal is automatically related to this AliTrack
1638 // (or derived) object.
1639 // Also a global link to this AliTrack (or derived) object will be stored
1640 // via the AddTrack() facility.
1644 // In case one just wants to relate the current AliSignal to a certain AliTrack
1645 // without a specific signal slot association, it is much more efficient
1646 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1648 // Please also have a look at the docs of the memberfunction ResetLink()
1649 // to prevent the situation of stored pointers to non-existent object.
1651 Int_t j=GetSlotIndex(name);
1652 if (j>0) SetLink(obj,j,k);
1654 ///////////////////////////////////////////////////////////////////////////
1655 void AliSignal::AddLink(TObject* obj,Int_t j)
1657 // Introduce a link (=pointer) to an object for the j-th slot at the first
1659 // Only the pointer values are stored for (backward) reference, meaning
1660 // that the objects of which the pointers are stored are NOT owned
1661 // by the AliSignal object.
1664 // The first slot is at j=1 and the first position is at k=1.
1665 // j=1 is the default value.
1667 // If needed, the storage area for the links is increased automatically.
1669 // In case the pointer argument is zero, no link will be added.
1671 // In principle any object derived from TObject can be referred to by this
1673 // However, this "linking back" facility was introduced to enable AliSignal slots
1674 // to refer directly to the various AliTracks to which the AliSignal object itself
1675 // is related (see AliTrack::AddSignal).
1676 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1677 // object, the current signal is automatically related to this AliTrack
1678 // (or derived) object.
1679 // Also a global link to this AliTrack (or derived) object will be stored
1680 // via the AddTrack() facility.
1684 // In case one just wants to relate the current AliSignal to a certain AliTrack
1685 // without a specific signal slot association, it is much more efficient
1686 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1688 // Please also have a look at the docs of the memberfunction ResetLink()
1689 // to prevent the situation of stored pointers to non-existent object.
1691 if (!obj || j<=0) return;
1693 if (!fLinks) fLinks=new AliObjMatrix();
1696 Int_t n=GetNlinks(dum,j);
1698 for (Int_t k=1; k<=n; k++)
1707 ///////////////////////////////////////////////////////////////////////////
1708 void AliSignal::AddLink(TObject* obj,TString name)
1710 // Introduce a link (=pointer) to an object for the name-spec slot at the first
1712 // Only the pointer values are stored for (backward) reference, meaning
1713 // that the objects of which the pointers are stored are NOT owned
1714 // by the AliSignal object.
1716 // This procedure involves a slot-index search based on the specified name
1717 // at each invokation. This may become slow in case many slots have been
1718 // defined and/or when this procedure is invoked many times.
1719 // In such cases it is preferable to use indexed addressing in the user code
1720 // either directly or via a few invokations of GetSlotIndex().
1722 // In case the pointer argument is zero, indeed a value of zero will be
1723 // stored at the first free position of the specified slotname.
1725 // In principle any object derived from TObject can be referred to by this
1727 // However, this "linking back" facility was introduced to enable AliSignal slots
1728 // to refer directly to the various AliTracks to which the AliSignal object itself
1729 // is related (see AliTrack::AddSignal).
1730 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1731 // object, the current signal is automatically related to this AliTrack
1732 // (or derived) object.
1733 // Also a global link to this AliTrack (or derived) object will be stored
1734 // via the AddTrack() facility.
1738 // In case one just wants to relate the current AliSignal to a certain AliTrack
1739 // without a specific signal slot association, it is much more efficient
1740 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1742 // Please also have a look at the docs of the memberfunction ResetLink()
1743 // to prevent the situation of stored pointers to non-existent object.
1745 Int_t j=GetSlotIndex(name);
1746 if (j>0) AddLink(obj,j);
1748 ///////////////////////////////////////////////////////////////////////////
1749 void AliSignal::ResetLink(Int_t j,Int_t k)
1751 // Reset the link of the j-th slot at position k.
1754 // The first slot is at j=1 and the first position is at k=1.
1755 // j=1 and k=1 are the default values.
1757 // This memberfunction is intended to reset only 1 specified link location.
1758 // For extended functionality, please refer to the memberfuction ResetLinks().
1760 // In general the user should take care of properly clearing the corresponding
1761 // pointer here when the referred object is deleted.
1762 // However, this "linking back" facility was introduced to enable AliSignal slots
1763 // to refer directly to the various AliTracks to which the AliSignal object itself
1764 // is related (see AliTrack::AddSignal).
1765 // As such, the AliTrack destructor already takes care of clearing the corresponding
1766 // links from the various AliSignal slots for all the AliSignal objects that were
1767 // related to that AliTrack.
1768 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1769 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1770 // the AliSignal object when the corresponding AliTrack object is deleted.
1772 // Note : In the internal storage matrix slots=columns positions=rows
1773 if (fLinks) fLinks->RemoveObject(k,j);
1775 ///////////////////////////////////////////////////////////////////////////
1776 void AliSignal::ResetLink(TString name,Int_t k)
1778 // Reset the link of the name-specified slot at position k.
1780 // This memberfunction is intended to reset only 1 specified link location.
1781 // For extended functionality, please refer to the memberfuction ResetLinks().
1783 // This procedure involves a slot-index search based on the specified name
1784 // at each invokation. This may become slow in case many slots have been
1785 // defined and/or when this procedure is invoked many times.
1786 // In such cases it is preferable to use indexed addressing in the user code
1787 // either directly or via a few invokations of GetSlotIndex().
1789 Int_t j=GetSlotIndex(name);
1790 if (j>0) ResetLink(j,k);
1792 ///////////////////////////////////////////////////////////////////////////
1793 void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k)
1795 // Reset single or multiple slot link(s) according to user specified selections.
1799 // This facility only acts on the slot related links.
1800 // The global track reference list will not be affected.
1801 // To remove all references to AliTrack (or derived) objects, please
1802 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1804 // A link is only reset if the stored reference matches the argument "obj".
1805 // In case obj=0 no check on the matching of the stored reference is performed
1806 // and the stored link is always reset in accordance with the other
1807 // selection criteria.
1809 // In case the slot argument "j" is specified, only the links from that
1810 // specified slot will be deleted.
1811 // In case j=0 (default) no checking on the slot index is performed.
1813 // In case the position argument "k" is specified, only the links from that
1814 // specified position will be deleted.
1815 // In case k=0 (default) no checking on the position index is performed.
1817 // So, invokation of ResetLinks(obj) will remove all references to the
1818 // object "obj" from the total AliSignal, whereas ResetLinks(obj,j)
1819 // will remove all references to the object "obj" only from slot "j".
1823 // The first slot is indicated as j=1, whereas the first position is at k=1.
1825 // Invokation of ResetLinks(0,row,col) is equivalent to invoking the
1826 // memberfunction ResetLink(row,col).
1827 // Invoking the latter directly is slightly faster.
1829 // Invokation of ResetLinks(0) will reset all stored references in this AliSignal.
1831 // In general the user should take care of properly clearing the corresponding
1832 // pointer here when the referred object is deleted.
1833 // However, this "linking back" facility was introduced to enable AliSignal slots
1834 // to refer directly to the various AliTracks to which the AliSignal object itself
1835 // is related (see AliTrack::AddSignal).
1836 // As such, the AliTrack destructor already takes care of clearing the corresponding
1837 // links from the various AliSignal slots for all the AliSignal objects that were
1838 // related to that AliTrack.
1839 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1840 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1841 // the AliSignal object when the corresponding AliTrack object is deleted.
1843 if (!fLinks) return;
1845 if (!obj && !j && !k)
1851 // Note : In the internal storage matrix slots=columns positions=rows
1852 fLinks->RemoveObjects(obj,k,j);
1855 ///////////////////////////////////////////////////////////////////////////
1856 void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k)
1858 // Reset single or multiple slot link(s) according to user specified selections.
1862 // This facility only acts on the slot related links.
1863 // The global track reference list will not be affected.
1864 // To remove all references to AliTrack (or derived) objects, please
1865 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1867 // A link is only reset if the stored reference matches the argument "obj".
1868 // In case obj=0 no check on the matching of the stored reference is performed
1869 // and the stored link is always reset in accordance with the other
1870 // selection criteria.
1872 // In case the position argument "k" is specified, only the links from that
1873 // specified position will be deleted.
1874 // In case k=0 (default) no checking on the position index is performed.
1876 // This procedure involves a slot-index search based on the specified name
1877 // at each invokation. This may become slow in case many slots have been
1878 // defined and/or when this procedure is invoked many times.
1879 // In such cases it is preferable to use indexed addressing in the user code
1880 // either directly or via a few invokations of GetSlotIndex().
1882 // In general the user should take care of properly clearing the corresponding
1883 // pointer here when the referred object is deleted.
1884 // However, this "linking back" facility was introduced to enable AliSignal slots
1885 // to refer directly to the various AliTracks to which the AliSignal object itself
1886 // is related (see AliTrack::AddSignal).
1887 // As such, the AliTrack destructor already takes care of clearing the corresponding
1888 // links from the various AliSignal slots for all the AliSignal objects that were
1889 // related to that AliTrack.
1890 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1891 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1892 // the AliSignal object when the corresponding AliTrack object is deleted.
1894 Int_t j=GetSlotIndex(name);
1895 if (j>0) ResetLinks(obj,j,k);
1897 ///////////////////////////////////////////////////////////////////////////
1898 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const
1900 // Provide the slot and position indices of all the storage locations
1901 // of the specified object.
1902 // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays
1903 // from which the (j,k) pairs can be obtained from the corresponding
1904 // array indices like (j,k)=(js.At(i),ks.At(i)).
1905 // The integer return argument represents the number of (j,k) pairs which
1906 // were encountered for the specified object.
1908 // If obj=0 no object selection is performed and all (j,k) indices
1909 // of the stored references for all objects are returned.
1913 // As usual the convention is that slot and position numbering starts at 1.
1915 // This memberfunction always resets the two TArrayI arrays at the start.
1917 // This memberfunction can only be used to obtain the (j,k) indices
1918 // of the object as stored via the SetLink() or AddLink() memberfunction.
1919 // This means that in case the user has entered a TObjArray as object
1920 // (to increase the dimension of the resulting structure), the (j,k)
1921 // indices of that TObjArray are obtained and NOT the indices of the
1922 // actual objects contained in that TObjArray structure.
1927 // Note : In the internal storage matrix slots=columns positions=rows
1928 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js);
1931 ///////////////////////////////////////////////////////////////////////////
1932 Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const
1934 // Provide the position indices of all the storage locations of the
1935 // specified object in the j-th slot of this AliSignal.
1936 // The position indices are returned in the TArrayI array.
1937 // The integer return argument represents the number of storage locations which
1938 // were encountered for the specified object in the j-th slot.
1940 // If obj=0 no object selection is performed and all position indices
1941 // of the stored references for all objects of the j-th slot are returned.
1943 // If j=0 all slots will be scanned and all position indices matching the
1944 // object selection are returned.
1945 // Note that in this case multiple appearances of the same position index
1946 // will only be recorded once in the returned TArrayI array.
1950 // As usual the convention is that slot and position numbering starts at 1.
1952 // This memberfunction always resets the TArrayI array at the start.
1954 // This memberfunction can only be used to obtain the position indices
1955 // of the object as stored via the SetLink() or AddLink() memberfunction.
1956 // This means that in case the user has entered a TObjArray as object
1957 // (to increase the dimension of the resulting structure), the position
1958 // indices of that TObjArray are obtained and NOT the indices of the
1959 // actual objects contained in that TObjArray structure.
1963 // Note : In the internal storage matrix slots=columns positions=rows
1964 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j);
1967 ///////////////////////////////////////////////////////////////////////////
1968 Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const
1970 // Provide the position indices of all the storage locations of the
1971 // specified object in the name-specified slot of this AliSignal.
1972 // The position indices are returned in the TArrayI array.
1973 // The integer return argument represents the number of storage locations which
1974 // were encountered for the specified object in the j-th slot.
1976 // If obj=0 no object selection is performed and all position indices
1977 // of the stored references for all objects of the j-th slot are returned.
1979 // This procedure involves a slot-index search based on the specified name
1980 // at each invokation. This may become slow in case many slots have been
1981 // defined and/or when this procedure is invoked many times.
1982 // In such cases it is preferable to use indexed addressing in the user code
1983 // either directly or via a few invokations of GetSlotIndex().
1985 Int_t j=GetSlotIndex(name);
1987 if (j>0) n=GetIndices(obj,j,ks);
1990 ///////////////////////////////////////////////////////////////////////////
1991 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const
1993 // Provide the slot indices of all the storage locations of the
1994 // specified object for the k-th position in this AliSignal.
1995 // The slot indices are returned in the TArrayI array.
1996 // The integer return argument represents the number of storage locations which
1997 // were encountered for the specified object in the k-th position.
1999 // If obj=0 no object selection is performed and all slot indices
2000 // of the stored references for all objects in the k-th position are returned.
2002 // If k=0 all positions will be scanned and all slot indices matching the
2003 // object selection are returned.
2004 // Note that in this case multiple appearances of the same slot index
2005 // will only be recorded once in the returned TArrayI array.
2009 // As usual the convention is that slot and position numbering starts at 1.
2011 // This memberfunction always resets the TArrayI array at the start.
2013 // This memberfunction can only be used to obtain the slot indices
2014 // of the object as stored via the SetLink() or AddLink() memberfunction.
2015 // This means that in case the user has entered a TObjArray as object
2016 // (to increase the dimension of the resulting structure), the slot
2017 // indices of that TObjArray are obtained and NOT the indices of the
2018 // actual objects contained in that TObjArray structure.
2022 // Note : In the internal storage matrix slots=columns positions=rows
2023 if (fLinks) nrefs=fLinks->GetIndices(obj,k,js);
2026 ///////////////////////////////////////////////////////////////////////////
2027 void AliSignal::SetSwapMode(Int_t swap)
2029 // Set swapmode flag for the internal link storage.
2030 // In case for the stored links the maximum slot number differs considerably
2031 // from the maximum position number, it might be more efficient
2032 // (w.r.t. memory usage and/or output file size) to internally store the
2033 // link reference matrix with the rows and colums swapped.
2034 // This swapping is only related with the internal storage and as such
2035 // is completely hidden for the user.
2036 // At invokation of this memberfunction the default argument is swap=1.
2038 // Note : The swap mode can only be set as long as no links are
2039 // stored in the AliSignal (i.e. a new instance of AliSignal
2040 // or after invokation of the Reset() or ResetLinks() function).
2042 if (!fLinks) fLinks=new AliObjMatrix();
2043 fLinks->SetSwapMode(swap);
2045 ///////////////////////////////////////////////////////////////////////////
2046 Int_t AliSignal::GetSwapMode() const
2048 // Provide swapmode flag of the link storage.
2050 if (fLinks) swap=fLinks->GetSwapMode();
2053 ///////////////////////////////////////////////////////////////////////////
2054 void AliSignal::SetDevice(TObject* dev)
2056 // Store the pointer to the device which owns this AliSignal object.
2057 // This memberfunction is meant for internal use in AliDevice.
2060 ///////////////////////////////////////////////////////////////////////////
2061 AliDevice* AliSignal::GetDevice() const
2063 // Provide the pointer to the device which owns this AliSignal object.
2064 return (AliDevice*)fDevice;
2066 ///////////////////////////////////////////////////////////////////////////
2067 void AliSignal::AddTrack(AliTrack& t,Int_t mode)
2069 // Relate an AliTrack object to this signal.
2070 // Only the pointer values are stored for (backward) reference, meaning
2071 // that the tracks of which the pointers are stored are NOT owned
2072 // by the AliSignal object.
2074 // mode = 0 : Only the reference to the specified track is stored in
2075 // the current signal, without storing the (backward) reference
2076 // to this signal into the AliTrack structure.
2077 // 1 : The (backward) reference to the current signal is also automatically
2078 // stored into the AliTrack (or derived) object specified in the
2081 // The default is mode=1.
2083 if (!fTracks) fTracks=new TObjArray(1);
2085 // Check if this track is already stored for this signal
2086 Int_t ntk=GetNtracks();
2087 for (Int_t i=0; i<ntk; i++)
2089 if (&t==fTracks->At(i)) return;
2093 if (mode==1) t.AddSignal(*this,0);
2095 ///////////////////////////////////////////////////////////////////////////
2096 void AliSignal::RemoveTrack(AliTrack& t,Int_t mode)
2098 // Remove related AliTrack object from this signal.
2099 // Also all references (if any) to this track in the slot links area
2102 // mode = 0 : All references to the specified track are removed from
2103 // the current signal, without removing the (backward) reference
2104 // to this signal from the AliTrack structure.
2105 // 1 : The (backward) reference to the current signal is also automatically
2106 // removed from the AliTrack (or derived) object specified in the
2109 // The default is mode=1.
2113 AliTrack* test=(AliTrack*)fTracks->Remove(&t);
2114 if (test) fTracks->Compress();
2119 if (mode==1) t.RemoveSignal(*this,0);
2121 ///////////////////////////////////////////////////////////////////////////
2122 void AliSignal::RemoveTracks(Int_t mode)
2124 // Remove all related AliTrack objects from this signal.
2125 // Also all references (if any) to the related tracks in the slot links area
2128 // mode = 0 : All track references are removed from the current signal,
2129 // without removing the (backward) references to this signal from
2130 // the corresponding AliTrack objects.
2131 // 1 : The (backward) references to the current signal are also automatically
2132 // removed from the corresponding AliTrack (or derived) objects.
2134 // The default is mode=1.
2136 if (!fTracks) return;
2138 Int_t ntk=GetNtracks();
2139 for (Int_t i=0; i<ntk; i++)
2141 AliTrack* tx=(AliTrack*)fTracks->At(i);
2145 if (mode==1) tx->RemoveSignal(*this,0);
2152 ///////////////////////////////////////////////////////////////////////////
2153 Int_t AliSignal::GetNtracks(AliTrack* t) const
2155 // Provide the number of related AliTracks.
2156 // In case an AliTrack pointer is specified as input argument,
2157 // the number returned will be the number of occurrences (i.e. 0 or 1)
2158 // for that specified track.
2159 // By default t=0, which implies that just the number of all associated
2160 // tracks will be returned.
2162 if (!fTracks) return 0;
2164 Int_t ntk=fTracks->GetEntries();
2168 for (Int_t i=0; i<ntk; i++)
2170 AliTrack* tx=(AliTrack*)fTracks->At(i);
2171 if (tx==t) return 1;
2176 ///////////////////////////////////////////////////////////////////////////
2177 AliTrack* AliSignal::GetTrack(Int_t j) const
2179 // Provide the related AliTrack number j.
2180 // Note : j=1 denotes the first track.
2182 if (!fTracks) return 0;
2184 if ((j >= 1) && (j <= GetNtracks()))
2186 return (AliTrack*)fTracks->At(j-1);
2190 cout << " *AliSignal* track number : " << j << " out of range."
2191 << " Ntk = " << GetNtracks() << endl;
2195 ///////////////////////////////////////////////////////////////////////////
2196 AliTrack* AliSignal::GetIdTrack(Int_t id) const
2198 // Return the track with user identifier "id" of this signal
2199 if (!fTracks) return 0;
2202 for (Int_t i=0; i<GetNtracks(); i++)
2204 tx=(AliTrack*)fTracks->At(i);
2205 if (id == tx->GetId()) return tx;
2207 return 0; // No matching id found
2209 ///////////////////////////////////////////////////////////////////////////
2210 TObject* AliSignal::Clone(const char* name) const
2212 // Make a deep copy of the current object and provide the pointer to the copy.
2213 // This memberfunction enables automatic creation of new objects of the
2214 // correct type depending on the object type, a feature which may be very useful
2215 // for containers when adding objects in case the container owns the objects.
2216 // This feature allows e.g. AliTrack to store either AliSignal objects or
2217 // objects derived from AliSignal via the AddSignal memberfunction, provided
2218 // these derived classes also have a proper Clone memberfunction.
2220 AliSignal* sig=new AliSignal(*this);
2223 if (strlen(name)) sig->SetName(name);
2227 ///////////////////////////////////////////////////////////////////////////