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 ///////////////////////////////////////////////////////////////////////////
112 #include "AliSignal.h"
113 #include "AliTrack.h"
114 #include "Riostream.h"
116 ClassImp(AliSignal) // Class implementation to enable ROOT I/O
118 AliSignal::AliSignal() : TNamed(),AliPosition(),AliAttrib()
120 // Creation of an AliSignal object and initialisation of parameters.
121 // Several signal values (with errors) can be stored in different slots.
122 // If needed, the storage for values (and errors) will be expanded automatically
123 // when entering values and/or errors.
132 ///////////////////////////////////////////////////////////////////////////
133 AliSignal::~AliSignal()
135 // Destructor to delete dynamically allocated memory
163 // Remove this signal from all related tracks
164 for (Int_t i=1; i<=GetNtracks(); i++)
166 AliTrack* tx=GetTrack(i);
167 if (tx) tx->RemoveSignal(*this,0);
173 ///////////////////////////////////////////////////////////////////////////
174 AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s)
184 // Don't copy the owning device pointer for the copy
187 Int_t n=s.GetNvalues();
189 for (Int_t i=1; i<=n; i++)
191 if (s.GetSignalFlag(i))
199 for (Int_t j=1; j<=n; j++)
201 if (s.GetErrorFlag(j))
203 val=s.GetSignalError(j);
204 SetSignalError(val,j);
209 for (Int_t k=1; k<=n; k++)
211 TH1F* hist=s.GetWaveform(k);
212 if (hist) SetWaveform(hist,k);
218 n=s.GetIndices(dum,slotarr,posarr);
220 for (Int_t idx=0; idx<n; idx++)
222 slot=slotarr.At(idx);
224 TObject* obj=s.GetLink(slot,pos);
225 if (obj) SetLink(obj,slot,pos);
228 Int_t ntk=s.GetNtracks();
231 fTracks=new TObjArray(ntk);
232 for (Int_t it=1; it<=ntk; it++)
234 AliTrack* tx=s.GetTrack(it);
239 ///////////////////////////////////////////////////////////////////////////
240 void AliSignal::Reset(Int_t mode)
242 // Reset all signal and position values and errors to 0.
244 // mode = 0 Reset position and all signal values and their errors to 0.
245 // The waveform histograms are reset, but the calibration
246 // constants (i.e. gains and offsets) are kept.
247 // 1 Reset position and delete the signal and error storage arrays.
248 // Also the waveform histograms, gains and offset arrays are deleted.
250 // The default when invoking Reset() corresponds to mode=0.
252 // Note : In all cases the storage of the various links will be reset.
253 // The UniqueID, name and title will NOT be reset.
254 // In case the user wants to reset these attributes, this has to
255 // be done explicitly via the SET facilities.
257 // The usage of mode=0 allows to re-use the allocated memory for new
258 // signal (and error) values. This behaviour is preferable (i.e. faster)
259 // in case the various signals always contain the same number of values
260 // and have the same calibration constants.
261 // The usage of mode=1 is slower, but allows a more efficient memory
262 // occupation (and smaller output file size) in case the different
263 // signals have a variable number of values.
265 // For more specific actions see ResetPosition(), ResetSignals(),
266 // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(),
267 // DeleteWaveform() and DeleteCalibrations().
270 if (mode<0 || mode>1)
272 cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl;
273 cout << " Default mode=0 will be used." << endl;
285 DeleteCalibrations();
288 if (fLinks) fLinks->Reset();
297 ///////////////////////////////////////////////////////////////////////////
298 void AliSignal::ResetSignals(Int_t mode)
300 // Reset various signal data according to user selection.
302 // mode = 0 Reset all signal values and their errors to 0.
303 // 1 Reset only signal values
304 // 2 Reset only signal errors
306 // The default when invoking ResetSignals() corresponds to mode=0.
308 // Irrespective of the mode, the waveform histograms are reset.
310 if (mode<0 || mode>2)
312 cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl;
313 cout << " Default mode=0 will be used." << endl;
320 if (fSignals && (mode==0 || mode==1))
322 for (Int_t i=1; i<=fSignals->GetSize(); i++)
324 fSignals->AddAt(0,i-1);
325 eflag=GetErrorFlag(i);
326 SetSigFlags(0,eflag,i);
330 if (fDsignals && (mode==0 || mode==2))
332 for (Int_t j=1; j<=fDsignals->GetSize(); j++)
334 fDsignals->AddAt(0,j-1);
335 sflag=GetSignalFlag(j);
336 SetSigFlags(sflag,0,j);
342 ///////////////////////////////////////////////////////////////////////////
343 void AliSignal::DeleteSignals(Int_t mode)
345 // Delete storage arrays of various signal data according to user selection.
347 // mode = 0 Delete arrays of both signal values and their errors.
348 // 1 Delete only signal values array
349 // 2 Delete only signal errors array
351 // The default when invoking DeleteSignals() corresponds to mode=0.
353 // Irrespective of the mode, the waveform histograms are deleted.
355 if (mode<0 || mode>2)
357 cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl;
358 cout << " Default mode=0 will be used." << endl;
362 if (fSignals && (mode==0 || mode==1))
368 if (fDsignals && (mode==0 || mode==2))
384 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
386 eflag=GetErrorFlag(i);
387 SetSigFlags(0,eflag,i);
392 for (Int_t j=1; j<=fSigflags->GetSize(); j++)
394 sflag=GetSignalFlag(j);
395 SetSigFlags(sflag,0,j);
401 ///////////////////////////////////////////////////////////////////////////
402 void AliSignal::SetSignal(Double_t sig,Int_t j)
404 // Store signal value for the j-th (default j=1) slot.
405 // Note : The first signal slot is at j=1.
406 // In case the value of the index j exceeds the maximum number of reserved
407 // slots for signal values, the number of reserved slots for the
408 // signal values is increased automatically.
412 fSignals=new TArrayF(j);
416 Int_t size=fSignals->GetSize();
423 fSignals->AddAt(float(sig),j-1);
425 Int_t eflag=GetErrorFlag(j);
426 SetSigFlags(1,eflag,j);
428 ///////////////////////////////////////////////////////////////////////////
429 void AliSignal::SetSignal(Double_t sig,TString name)
431 // Store signal value for the name-specified slot.
433 // This procedure involves a slot-index search based on the specified name
434 // at each invokation. This may become slow in case many slots have been
435 // defined and/or when this procedure is invoked many times.
436 // In such cases it is preferable to use indexed addressing in the user code
437 // either directly or via a few invokations of GetSlotIndex().
439 Int_t j=GetSlotIndex(name);
440 if (j>0) SetSignal(sig,j);
442 ///////////////////////////////////////////////////////////////////////////
443 void AliSignal::AddSignal(Double_t sig,Int_t j)
445 // Add value to the signal of the j-th (default j=1) slot.
446 // Note : The first signal slot is at j=1.
447 // In case the value of the index j exceeds the maximum number of reserved
448 // slots for signal values, the number of reserved slots for the
449 // signal values is increased automatically.
453 fSignals=new TArrayF(j);
457 Int_t size=fSignals->GetSize();
464 Float_t sum=(fSignals->At(j-1))+sig;
465 fSignals->AddAt(sum,j-1);
467 Int_t eflag=GetErrorFlag(j);
468 SetSigFlags(1,eflag,j);
470 ///////////////////////////////////////////////////////////////////////////
471 void AliSignal::AddSignal(Double_t sig,TString name)
473 // Add value to the signal of the name-specified slot.
475 // This procedure involves a slot-index search based on the specified name
476 // at each invokation. This may become slow in case many slots have been
477 // defined and/or when this procedure is invoked many times.
478 // In such cases it is preferable to use indexed addressing in the user code
479 // either directly or via a few invokations of GetSlotIndex().
481 Int_t j=GetSlotIndex(name);
482 if (j>0) AddSignal(sig,j);
484 ///////////////////////////////////////////////////////////////////////////
485 Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const
487 // Provide signal value of the j-th (default j=1) slot.
488 // Note : The first signal slot is at j=1.
489 // In case no signal is present or the input argument "j" or "mode" is invalid,
490 // the value 0 is returned.
491 // The parameter "mode" allows for automatic (de)calibration of the signal
492 // (e.g. gain etc... correction or via explicit (de)calibration functions).
494 // mode = 0 : Just the j-th signal is returned.
495 // 1 : The j-th signal is corrected for the gain, offset, dead flag etc...
496 // In case the j-th slot was marked dead, 0 is returned.
497 // In case the gain value was not set, gain=1 will be assumed.
498 // In case the gain value was 0, a signal value of 0 is returned.
499 // In case the offset value was not set, offset=0 will be assumed.
500 // 2 : Same as mode=1 but gain, offset dead flag etc... are taken from
501 // the AliDevice which owns this AliSignal object.
502 // The corresponding AliDevice slot is obtained via matching of
503 // the slotnames. In case this fails, the slotindex "j" of the
504 // input argument will be used.
505 // In case this AliSignal object has no parent AliDevice, just
506 // the j-th signal is returned (like with mode=0).
507 // 3 : The j-th signal is corrected using the corresponding calibration
509 // In case the j-th slot was marked dead, 0 is returned.
510 // In case no calibration function is present, just the j-th signal
511 // is returned (like with mode=0).
512 // 4 : Same as mode=3 but the calibration function and dead flag are
513 // taken from the AliDevice which owns this AliSignal object.
514 // The corresponding AliDevice slot is obtained via matching of
515 // the slotnames. In case this fails, the slotindex "j" of the
516 // input argument will be used.
517 // 5 : Same as mode=2 but in case no parent AliDevice is present
518 // an automatic switch to mode=1 will be made.
519 // 6 : Same as mode=4 but in case no parent AliDevice is present
520 // an automatic switch to mode=3 will be made.
521 // 7 : Same as mode=3 but in case no calibration function is present
522 // an automatic switch to mode=4 will be made.
523 // 8 : Same as mode=7 but also the corresponding dead flag of the
524 // parent device (if any) will be checked.
525 // If either the dead flag of the requested signal slot of this
526 // AliSignal object or the corresponding parent device slot is
527 // set, 0 is returned.
529 // <0 : The corresponding de-correction or de-calibration is performed
531 // The corrected signal (sigc) is determined as follows :
533 // sigc=(signal/gain)-offset
535 // The de-corrected signal is determined as follows :
537 // signal=(sigc+offset)*gain
539 // The default is mode=0.
541 if (abs(mode)>8) return 0;
548 // Get the corresponding slot index (and dead flag) of the parent device
551 AliSignal* parent=(AliSignal*)GetDevice();
552 if ((abs(mode)==2 || abs(mode)>=4) && parent)
554 TString name=GetSlotName(j);
555 if (strlen(name.Data())) pj=parent->GetSlotIndex(name);
556 if (abs(mode)==8 && pj) pdead=parent->GetDeadValue(pj);
559 if (mode==-8) mode=-7;
561 AliSignal* sx=(AliSignal*)this;
566 f=sx->GetCalFunction(jcal);
578 f=sx->GetDecalFunction(jcal);
589 if (abs(mode)==2 || abs(mode)>=4)
591 sx=(AliSignal*)GetDevice();
594 if (!sx && abs(mode)>=5) sx=(AliSignal*)this;
596 if (mode==-5) mode=-2;
598 if (mode==-6) mode=-3;
602 if (j>0 && j<=(fSignals->GetSize()))
604 sig=fSignals->At(j-1);
606 if (mode==0 || !sx) return sig;
608 // Check for the dead flag setting
609 if (sx->GetDeadValue(jcal) || pdead) return 0;
611 // (De)correct the signal for the gain and offset
612 if (abs(mode)==1 || abs(mode)==2)
614 if (sx->GetGainFlag(jcal)) gain=sx->GetGain(jcal);
615 if (sx->GetOffsetFlag(jcal)) offset=sx->GetOffset(jcal);
619 if (mode>0) sig=(sig/gain)-offset; // Gain and offset correction
620 if (mode<0) sig=(sig+offset)*gain; // Gain and offset de-correction
629 // (De)calibrate the signal with the corresponding (de)calibration function
630 if (abs(mode)==3 || abs(mode)==4)
632 f=sx->GetCalFunction(jcal);
633 if (mode<0) f=sx->GetDecalFunction(jcal);
634 if (f) sig=f->Eval(sig);
640 cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl;
645 ///////////////////////////////////////////////////////////////////////////
646 Float_t AliSignal::GetSignal(TString name,Int_t mode) const
648 // Provide signal value of the name-specified slot.
649 // In case no signal is present, 0 is returned.
650 // The parameter "mode" allows for automatic (de)calibration of the signal
651 // (e.g. gain etc... correction or via explicit (de)calibration functions).
652 // For further details about the (de)calibration modes, please refer to the
653 // corresponding slot-index based memberfunction.
655 // The default is mode=0.
657 // This procedure involves a slot-index search based on the specified name
658 // at each invokation. This may become slow in case many slots have been
659 // defined and/or when this procedure is invoked many times.
660 // In such cases it is preferable to use indexed addressing in the user code
661 // either directly or via a few invokations of GetSlotIndex().
663 Int_t j=GetSlotIndex(name);
665 if (j>0) val=GetSignal(j,mode);
668 ///////////////////////////////////////////////////////////////////////////
669 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
671 // Store error on the signal for the j-th (default j=1) slot.
672 // Note : The first signal slot is at j=1.
673 // In case the value of the index j exceeds the maximum number of reserved
674 // slots for signal error values, the number of reserved slots for the
675 // signal errors is increased automatically.
679 fDsignals=new TArrayF(j);
683 Int_t size=fDsignals->GetSize();
690 fDsignals->AddAt(float(dsig),j-1);
692 Int_t sflag=GetSignalFlag(j);
693 SetSigFlags(sflag,1,j);
695 ///////////////////////////////////////////////////////////////////////////
696 void AliSignal::SetSignalError(Double_t dsig,TString name)
698 // Store error on the signal for the name-specified slot.
700 // This procedure involves a slot-index search based on the specified name
701 // at each invokation. This may become slow in case many slots have been
702 // defined and/or when this procedure is invoked many times.
703 // In such cases it is preferable to use indexed addressing in the user code
704 // either directly or via a few invokations of GetSlotIndex().
706 Int_t j=GetSlotIndex(name);
707 if (j>0) SetSignalError(dsig,j);
709 ///////////////////////////////////////////////////////////////////////////
710 Float_t AliSignal::GetSignalError(Int_t j) const
712 // Provide error on the signal of the j-th (default j=1) slot.
713 // Note : The first signal slot is at j=1.
714 // In case no signal is present or the argument j is invalid, 0 is returned.
718 if (j>0 && j<=(fDsignals->GetSize()))
720 err=fDsignals->At(j-1);
724 cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl;
729 ///////////////////////////////////////////////////////////////////////////
730 Float_t AliSignal::GetSignalError(TString name) const
732 // Provide error on the signal of the name-specified slot.
734 // This procedure involves a slot-index search based on the specified name
735 // at each invokation. This may become slow in case many slots have been
736 // defined and/or when this procedure is invoked many times.
737 // In such cases it is preferable to use indexed addressing in the user code
738 // either directly or via a few invokations of GetSlotIndex().
740 Int_t j=GetSlotIndex(name);
742 if (j>0) val=GetSignalError(j);
745 ///////////////////////////////////////////////////////////////////////////
746 void AliSignal::Data(TString f,TString u) const
748 // Provide all signal information within the coordinate frame f.
750 // The string argument "u" allows to choose between different angular units
751 // in case e.g. a spherical frame is selected.
752 // u = "rad" : angles provided in radians
753 // "deg" : angles provided in degrees
755 // The defaults are f="car" and u="rad".
757 const char* name=GetName();
758 const char* title=GetTitle();
760 cout << " *" << ClassName() << "::Data* Id : " << GetUniqueID();
761 if (strlen(name)) cout << " Name : " << name;
762 if (strlen(title)) cout << " Title : " << title;
765 AliPosition::Data(f,u);
768 const char* devname=fDevice->GetName();
769 const char* devtitle=fDevice->GetTitle();
770 cout << " Owned by device : " << fDevice->ClassName()
771 << " Id : " << fDevice->GetUniqueID();
772 if (strlen(devname)) cout << " Name : " << devname;
773 if (strlen(devtitle)) cout << " Title : " << devtitle;
777 // Provide an overview of the stored waveforms
780 // Provide an overview of the associated tracks
783 // Provide an overview of all the data and attribute slots
786 ///////////////////////////////////////////////////////////////////////////
787 void AliSignal::List(Int_t j) const
789 // Provide signal information for the j-th slot.
790 // The first slot is at j=1.
791 // In case j=0 (default) the data of all slots will be listed.
792 // In case j=-1 the data of all slots will be listed, but the header
793 // information will be suppressed.
797 cout << " *AliSignal::List* Invalid argument j = " << j << endl;
803 const char* name=GetName();
804 const char* title=GetTitle();
806 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
807 if (strlen(name)) cout << " Name : " << name;
808 if (strlen(title)) cout << " Title : " << title;
812 const char* devname=fDevice->GetName();
813 const char* devtitle=fDevice->GetTitle();
814 cout << " Owned by device : " << fDevice->ClassName();
815 if (strlen(devname)) cout << " Name : " << devname;
816 if (strlen(devtitle)) cout << " Title : " << devtitle;
823 if (GetNlinks()) nlinkslots=fLinks->GetMaxColumn();
824 if (nlinkslots>n) n=nlinkslots;
833 for (Int_t i=1; i<=n; i++)
836 nrefs=GetIndices(obj,i,posarr);
838 if (GetSignalFlag(i) || GetErrorFlag(i) || GetCalFunction(i) || GetDecalFunction(i) || GetCalWord(i) || nrefs)
840 cout << " Slot : " << i;
841 if (GetSignalFlag(i)) cout << " Signal value : " << GetSignal(i);
842 if (GetErrorFlag(i)) cout << " error : " << GetSignalError(i);
846 for (Int_t k=0; k<nrefs; k++)
852 cout << " Link at position " << pos << " to : " << obj->ClassName();
853 if (obj->InheritsFrom("TNamed"))
855 const char* lname=obj->GetName();
856 const char* ltitle=obj->GetTitle();
857 if (strlen(lname)) cout << " Name : " << lname;
858 if (strlen(ltitle)) cout << " Title : " << ltitle;
871 nrefs=GetIndices(obj,j,posarr);
873 if (GetSignalFlag(j) || GetErrorFlag(j) || GetCalFunction(j) || GetDecalFunction(j) || GetCalWord(j) || nrefs)
875 cout << " Slot : " << j;
876 if (GetSignalFlag(j)) cout << " Signal value : " << GetSignal(j);
877 if (GetErrorFlag(j)) cout << " error : " << GetSignalError(j);
881 for (Int_t kj=0; kj<nrefs; kj++)
887 cout << " Link at position " << pos << " to : " << obj->ClassName();
888 if (obj->InheritsFrom("TNamed"))
890 const char* lnamej=obj->GetName();
891 const char* ltitlej=obj->GetTitle();
892 if (strlen(lnamej)) cout << " Name : " << lnamej;
893 if (strlen(ltitlej)) cout << " Title : " << ltitlej;
902 ///////////////////////////////////////////////////////////////////////////
903 void AliSignal::List(TString name) const
905 // Provide signal information for the name-specified slot.
907 // This procedure involves a slot-index search based on the specified name
908 // at each invokation. This may become slow in case many slots have been
909 // defined and/or when this procedure is invoked many times.
910 // In such cases it is preferable to use indexed addressing in the user code
911 // either directly or via a few invokations of GetSlotIndex().
913 Int_t j=GetSlotIndex(name);
916 ///////////////////////////////////////////////////////////////////////////
917 void AliSignal::ListWaveform(Int_t j) const
919 // Provide information for the j-th waveform.
920 // The first waveform is at j=1.
921 // In case j=0 (default) the info of all waveforms will be listed.
922 // In case j=-1 the info of all waveforms will be listed, but the header
923 // information will be suppressed.
927 cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl;
933 const char* name=GetName();
934 const char* title=GetTitle();
936 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
937 if (strlen(name)) cout << " Name : " << name;
938 if (strlen(title)) cout << " Title : " << title;
942 const char* devname=fDevice->GetName();
943 const char* devtitle=fDevice->GetTitle();
944 cout << " Owned by device : " << fDevice->ClassName();
945 if (strlen(devname)) cout << " Name : " << devname;
946 if (strlen(devtitle)) cout << " Title : " << devtitle;
951 Int_t n=GetNwaveforms();
956 for (Int_t i=1; i<=n; i++)
961 const char* wfname=obj->GetName();
962 const char* wftitle=obj->GetTitle();
963 cout << " Waveform " << i << " : " << obj->ClassName();
964 if (strlen(wfname)) cout << " Name : " << wfname;
965 if (strlen(wftitle)) cout << " Title : " << wftitle;
977 const char* wfnamej=obj->GetName();
978 const char* wftitlej=obj->GetTitle();
979 cout << " Waveform " << j << " : " << obj->ClassName();
980 if (strlen(wfnamej)) cout << " Name : " << wfnamej;
981 if (strlen(wftitlej)) cout << " Title : " << wftitlej;
987 ///////////////////////////////////////////////////////////////////////////
988 void AliSignal::ListTrack(Int_t j) const
990 // Provide information for the j-th associated track.
991 // The first associated track is at j=1.
992 // In case j=0 (default) the info of all associated tracks will be listed.
993 // In case j=-1 the info of all tracks will be listed, but the header
994 // information will be suppressed.
998 cout << " *AliSignal::ListTrack* Invalid argument j = " << j << endl;
1004 const char* name=GetName();
1005 const char* title=GetTitle();
1007 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
1008 if (strlen(name)) cout << " Name : " << name;
1009 if (strlen(title)) cout << " Title : " << title;
1013 const char* devname=fDevice->GetName();
1014 const char* devtitle=fDevice->GetTitle();
1015 cout << " Owned by device : " << fDevice->ClassName();
1016 if (strlen(devname)) cout << " Name : " << devname;
1017 if (strlen(devtitle)) cout << " Title : " << devtitle;
1022 Int_t n=GetNtracks();
1027 for (Int_t i=1; i<=n; i++)
1032 const char* txname=tx->GetName();
1033 const char* txtitle=tx->GetTitle();
1034 cout << " Track " << i << " : " << tx->ClassName() << " Id : " << tx->GetId();
1035 if (strlen(txname)) cout << " Name : " << txname;
1036 if (strlen(txtitle)) cout << " Title : " << txtitle;
1048 const char* txnamej=tx->GetName();
1049 const char* txtitlej=tx->GetTitle();
1050 cout << " Track " << j << " : " << tx->ClassName() << " Id : " << tx->GetId();
1051 if (strlen(txnamej)) cout << " Name : " << txnamej;
1052 if (strlen(txtitlej)) cout << " Title : " << txtitlej;
1058 ///////////////////////////////////////////////////////////////////////////
1059 Int_t AliSignal::GetNvalues() const
1061 // Provide the number of values for this signal.
1063 if (!fSignals) return 0;
1066 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
1068 if (GetSignalFlag(i)) n=i;
1073 ///////////////////////////////////////////////////////////////////////////
1074 Int_t AliSignal::GetNerrors() const
1076 // Provide the number specified errors on the values for this signal.
1078 if (!fDsignals) return 0;
1081 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
1083 if (GetErrorFlag(i)) n=i;
1088 ///////////////////////////////////////////////////////////////////////////
1089 void AliSignal::SetSigFlags(Int_t is,Int_t ie,Int_t j)
1091 // Store signal and/or error value flags of the j-th (default j=1) slot.
1092 // Note : The first slot is at j=1.
1093 // In case the value of the index j exceeds the maximum number of reserved
1094 // slots for the flags, the number of reserved slots for the flags is
1095 // increased automatically.
1096 // The value stored is : 10*signalflag + errorflag.
1100 cout << " *AliSignal::SetSigFlags* Invalid argument j = " << j << endl;
1106 fSigflags=new TArrayI(j);
1109 Int_t size=fSigflags->GetSize();
1116 Int_t word=10*is+ie;
1118 fSigflags->AddAt(word,j-1);
1120 ///////////////////////////////////////////////////////////////////////////
1121 Int_t AliSignal::GetSignalFlag(Int_t j) const
1123 // Provide signal value flag of the j-th (default j=1) slot.
1125 // flag = 1 : Signal value was set
1126 // 0 : Signal value was not set
1128 // Note : The first attribute slot is at j=1.
1129 // In case j is invalid, 0 is returned.
1133 cout << " *AliSignal::GetSignalFlag* Invalid argument j = " << j << endl;
1139 if (j>0 && j<=(fSigflags->GetSize()))
1141 Int_t word=fSigflags->At(j-1);
1147 ///////////////////////////////////////////////////////////////////////////
1148 Int_t AliSignal::GetSignalFlag(TString name) const
1150 // Provide signal value flag of the name-specified slot.
1152 // flag = 1 : Signal value was set
1153 // 0 : Signal value was not set
1156 // This procedure involves a slot-index search based on the specified name
1157 // at each invokation. This may become slow in case many slots have been
1158 // defined and/or when this procedure is invoked many times.
1159 // In such cases it is preferable to use indexed addressing in the user code
1160 // either directly or via a few invokations of GetSlotIndex().
1162 Int_t j=GetSlotIndex(name);
1164 if (j>0) flag=GetSignalFlag(j);
1167 ///////////////////////////////////////////////////////////////////////////
1168 Int_t AliSignal::GetErrorFlag(Int_t j) const
1170 // Provide error value flag of the j-th (default j=1) slot.
1172 // flag = 1 : Error value was set
1173 // 0 : Error value was not set
1175 // Note : The first attribute slot is at j=1.
1176 // In case j is invalid, 0 is returned.
1180 cout << " *AliSignal::GetErrorFlag* Invalid argument j = " << j << endl;
1186 if (j>0 && j<=(fSigflags->GetSize()))
1188 Int_t word=fSigflags->At(j-1);
1194 ///////////////////////////////////////////////////////////////////////////
1195 Int_t AliSignal::GetErrorFlag(TString name) const
1197 // Provide error value flag of the name-specified slot.
1199 // flag = 1 : Error value was set
1200 // 0 : Error value was not set
1203 // This procedure involves a slot-index search based on the specified name
1204 // at each invokation. This may become slow in case many slots have been
1205 // defined and/or when this procedure is invoked many times.
1206 // In such cases it is preferable to use indexed addressing in the user code
1207 // either directly or via a few invokations of GetSlotIndex().
1209 Int_t j=GetSlotIndex(name);
1211 if (j>0) flag=GetErrorFlag(j);
1214 ///////////////////////////////////////////////////////////////////////////
1215 Int_t AliSignal::GetNslots() const
1217 // Provide the number of existing slots.
1219 Int_t n=AliAttrib::GetNslots();
1221 if (!fSigflags) return n;
1224 for (Int_t i=0; i<fSigflags->GetSize(); i++)
1226 if (fSigflags->At(i)) nflags=i+1;
1229 if (n<nflags) n=nflags;
1233 ///////////////////////////////////////////////////////////////////////////
1234 Int_t AliSignal::GetNwaveforms() const
1236 // Provide the number of specified waveforms for this signal.
1237 // Actually the return value is the highest index of the stored waveforms.
1238 // This allows an index dependent meaning of waveform info (e.g. waveforms
1239 // with various gain values).
1240 // So, when all waveforms are stored in consequetive positions (e.g. 1,2,3),
1241 // this memberfunction returns 3, being both the highest filled position
1242 // and the actual number of waveforms.
1243 // In case only waveforms are stored at positions 1,2,5,7 this memberfunction
1244 // returns a value 7 whereas only 4 actual waveforms are present.
1245 // This implies that when looping over the various waveform slots, one
1246 // always has to check whether the returned pointer value is non-zero
1247 // (which is a good practice anyhow).
1249 if (fWaveforms) n=fWaveforms->GetLast();
1252 ///////////////////////////////////////////////////////////////////////////
1253 TH1F* AliSignal::GetWaveform(Int_t j) const
1255 // Provide pointer to the j-th waveform histogram.
1257 if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1);
1260 ///////////////////////////////////////////////////////////////////////////
1261 TH1F* AliSignal::GetWaveform(TString name) const
1263 // Provide pointer to the waveform histogram with the specified name.
1264 // In case no match is found, zero is returned.
1265 Int_t n=GetNwaveforms();
1267 for (Int_t i=1; i<=n; i++)
1269 TH1F* waveform=GetWaveform(i);
1272 str=waveform->GetName();
1273 if (str == name) return waveform;
1276 return 0; // No match found
1278 ///////////////////////////////////////////////////////////////////////////
1279 Int_t AliSignal::GetWaveformIndex(TString name) const
1281 // Provide index to the waveform histogram with the specified name.
1282 // In case no match is found, zero is returned.
1283 Int_t n=GetNwaveforms();
1285 for (Int_t i=1; i<=n; i++)
1287 TH1F* waveform=GetWaveform(i);
1290 str=waveform->GetName();
1291 if (str == name) return i;
1294 return 0; // No match found
1296 ///////////////////////////////////////////////////////////////////////////
1297 void AliSignal::SetWaveform(TH1F* waveform,Int_t j)
1299 // Set the 1D waveform histogram for the j-th waveform.
1302 // The first waveform position at j=1.
1303 // j=1 is the default value.
1305 // In case the value of the index j exceeds the maximum number of reserved
1306 // positions for the waveforms, the number of reserved positions for the waveforms
1307 // is increased automatically.
1309 // In case the histo pointer argument has the same value as the current waveform
1310 // histogram pointer value, no action is taken since the user has already
1311 // modified the actual histogram.
1313 // In case the histo pointer argument is zero, the current waveform histogram
1314 // is deleted and the pointer set to zero.
1316 // In all other cases the current waveform histogram is deleted and a new
1317 // copy of the input histogram is created which becomes the current waveform
1324 fWaveforms=new TObjArray(j);
1325 fWaveforms->SetOwner();
1328 if (j > fWaveforms->GetSize()) fWaveforms->Expand(j);
1330 TH1F* hcur=(TH1F*)fWaveforms->At(j-1);
1331 if (waveform != hcur)
1335 fWaveforms->Remove(hcur);
1341 hcur=new TH1F(*waveform);
1342 fWaveforms->AddAt(hcur,j-1);
1346 ///////////////////////////////////////////////////////////////////////////
1347 void AliSignal::ResetWaveform(Int_t j)
1349 // Reset the histogram of the j-th (default j=1) waveform.
1350 // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s).
1351 // To actually delete the histograms from memory, use DeleteWaveform().
1352 // Notes : The first position is at j=1.
1353 // j=0 ==> All waveforms will be reset.
1355 if (!fWaveforms) return;
1357 Int_t size=fWaveforms->GetSize();
1359 if ((j>=0) && (j<=size))
1363 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1364 if (hwave) hwave->Reset();
1368 for (Int_t i=0; i<size; i++)
1370 TH1F* hwave=(TH1F*)fWaveforms->At(i);
1371 if (hwave) hwave->Reset();
1377 cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl;
1381 ///////////////////////////////////////////////////////////////////////////
1382 void AliSignal::ResetWaveform(TString name)
1384 // Reset the waveform with the specified name.
1385 Int_t j=GetWaveformIndex(name);
1386 if (j>0) ResetWaveform(j);
1388 ///////////////////////////////////////////////////////////////////////////
1389 void AliSignal::DeleteWaveform(Int_t j)
1391 // Delete the histogram of the j-th (default j=1) waveform.
1392 // Notes : The first position is at j=1.
1393 // j=0 ==> All waveforms will be deleted.
1395 if (!fWaveforms) return;
1397 Int_t size=fWaveforms->GetSize();
1399 if ((j>=0) && (j<=size))
1403 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1406 fWaveforms->Remove(hwave);
1418 cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl;
1422 ///////////////////////////////////////////////////////////////////////////
1423 void AliSignal::DeleteWaveform(TString name)
1425 // Delete the waveform with the specified name.
1426 Int_t j=GetWaveformIndex(name);
1427 if (j>0) DeleteWaveform(j);
1429 ///////////////////////////////////////////////////////////////////////////
1430 Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const
1432 // Provide the number of links to the specified object for the j-th slot.
1433 // If j=0 (default) all slots will be scanned for the specified object.
1434 // If obj=0 (default) all encountered objects for the specified slot will be counted.
1435 // So, invokation of the default GetNlinks() will return the total number of
1436 // all references to all sorts of stored objects.
1439 cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl;
1443 if (!fLinks) return 0;
1448 n=fLinks->GetNrefs(obj);
1453 n=GetIndices(obj,j,posarr);
1457 ///////////////////////////////////////////////////////////////////////////
1458 Int_t AliSignal::GetNlinks(TObject* obj,TString name) const
1460 // Provide the number of links to the specified object for the name-spec. slot.
1461 // If obj=0 all encountered objects for the specified slot will be counted.
1463 // This procedure involves a slot-index search based on the specified name
1464 // at each invokation. This may become slow in case many slots have been
1465 // defined and/or when this procedure is invoked many times.
1466 // In such cases it is preferable to use indexed addressing in the user code
1467 // either directly or via a few invokations of GetSlotIndex().
1469 Int_t j=GetSlotIndex(name);
1471 if (j>0) n=GetNlinks(obj,j);
1474 ///////////////////////////////////////////////////////////////////////////
1475 TObject* AliSignal::GetLink(Int_t j,Int_t k) const
1477 // Provide pointer of the object linked to the j-th slot at position k.
1480 // Note : In the internal storage matrix slots=columns positions=rows
1481 if (fLinks) obj=fLinks->GetObject(k,j);
1484 ///////////////////////////////////////////////////////////////////////////
1485 TObject* AliSignal::GetLink(TString name,Int_t k) const
1487 // Provide pointer of the object linked to the name-spec. slot at position k.
1489 // This procedure involves a slot-index search based on the specified name
1490 // at each invokation. This may become slow in case many slots have been
1491 // defined and/or when this procedure is invoked many times.
1492 // In such cases it is preferable to use indexed addressing in the user code
1493 // either directly or via a few invokations of GetSlotIndex().
1495 Int_t j=GetSlotIndex(name);
1497 if (j>0) obj=GetLink(j,k);
1500 ///////////////////////////////////////////////////////////////////////////
1501 void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k)
1503 // Introduce a link (=pointer) to an object for the j-th slot at position k.
1504 // Only the pointer values are stored for (backward) reference, meaning
1505 // that the objects of which the pointers are stored are NOT owned
1506 // by the AliSignal object.
1509 // The first slot is at j=1 and the first position is at k=1.
1510 // j=1 and k=1 are the default values.
1512 // If needed, the storage area for the links is increased automatically.
1514 // In case the pointer argument is zero, indeed a value of zero will be
1515 // stored at the specified position (k) for the specified slot (j).
1517 // In principle any object derived from TObject can be referred to by this
1519 // However, this "linking back" facility was introduced to enable AliSignal slots
1520 // to refer directly to the various AliTracks to which the AliSignal object itself
1521 // is related (see AliTrack::AddSignal).
1522 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1523 // object, the current signal is automatically related to this AliTrack
1524 // (or derived) object.
1525 // Also a global link to this AliTrack (or derived) object will be stored
1526 // via the AddTrack() facility.
1530 // In case one just wants to relate the current AliSignal to a certain AliTrack
1531 // without a specific signal slot association, it is much more efficient
1532 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1534 // Please also have a look at the docs of the memberfunction ResetLink()
1535 // to prevent the situation of stored pointers to non-existent object.
1537 if (!fLinks && obj) fLinks=new AliObjMatrix();
1539 if (!fLinks) return;
1541 // Note : In the internal storage matrix slots=columns positions=rows
1542 fLinks->EnterObject(k,j,obj);
1545 if (obj->InheritsFrom("AliTrack"))
1547 AliTrack* t=(AliTrack*)obj;
1552 ///////////////////////////////////////////////////////////////////////////
1553 void AliSignal::SetLink(TObject* obj,TString name,Int_t k)
1555 // Introduce a link (=pointer) to an object for the name-spec. slot at position k.
1556 // Only the pointer values are stored for (backward) reference, meaning
1557 // that the objects of which the pointers are stored are NOT owned
1558 // by the AliSignal object.
1560 // This procedure involves a slot-index search based on the specified name
1561 // at each invokation. This may become slow in case many slots have been
1562 // defined and/or when this procedure is invoked many times.
1563 // In such cases it is preferable to use indexed addressing in the user code
1564 // either directly or via a few invokations of GetSlotIndex().
1566 // In case the pointer argument is zero, indeed a value of zero will be
1567 // stored at the specified position (k) for the specified slotname.
1569 // In principle any object derived from TObject can be referred to by this
1571 // However, this "linking back" facility was introduced to enable AliSignal slots
1572 // to refer directly to the various AliTracks to which the AliSignal object itself
1573 // is related (see AliTrack::AddSignal).
1574 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1575 // object, the current signal is automatically related to this AliTrack
1576 // (or derived) object.
1577 // Also a global link to this AliTrack (or derived) object will be stored
1578 // via the AddTrack() facility.
1582 // In case one just wants to relate the current AliSignal to a certain AliTrack
1583 // without a specific signal slot association, it is much more efficient
1584 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1586 // Please also have a look at the docs of the memberfunction ResetLink()
1587 // to prevent the situation of stored pointers to non-existent object.
1589 Int_t j=GetSlotIndex(name);
1590 if (j>0) SetLink(obj,j,k);
1592 ///////////////////////////////////////////////////////////////////////////
1593 void AliSignal::AddLink(TObject* obj,Int_t j)
1595 // Introduce a link (=pointer) to an object for the j-th slot at the first
1597 // Only the pointer values are stored for (backward) reference, meaning
1598 // that the objects of which the pointers are stored are NOT owned
1599 // by the AliSignal object.
1602 // The first slot is at j=1 and the first position is at k=1.
1603 // j=1 is the default value.
1605 // If needed, the storage area for the links is increased automatically.
1607 // In case the pointer argument is zero, no link will be added.
1609 // In principle any object derived from TObject can be referred to by this
1611 // However, this "linking back" facility was introduced to enable AliSignal slots
1612 // to refer directly to the various AliTracks to which the AliSignal object itself
1613 // is related (see AliTrack::AddSignal).
1614 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1615 // object, the current signal is automatically related to this AliTrack
1616 // (or derived) object.
1617 // Also a global link to this AliTrack (or derived) object will be stored
1618 // via the AddTrack() facility.
1622 // In case one just wants to relate the current AliSignal to a certain AliTrack
1623 // without a specific signal slot association, it is much more efficient
1624 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1626 // Please also have a look at the docs of the memberfunction ResetLink()
1627 // to prevent the situation of stored pointers to non-existent object.
1629 if (!obj || j<=0) return;
1631 if (!fLinks) fLinks=new AliObjMatrix();
1634 Int_t n=GetNlinks(dum,j);
1636 for (Int_t k=1; k<=n; k++)
1645 ///////////////////////////////////////////////////////////////////////////
1646 void AliSignal::AddLink(TObject* obj,TString name)
1648 // Introduce a link (=pointer) to an object for the name-spec slot at the first
1650 // Only the pointer values are stored for (backward) reference, meaning
1651 // that the objects of which the pointers are stored are NOT owned
1652 // by the AliSignal object.
1654 // This procedure involves a slot-index search based on the specified name
1655 // at each invokation. This may become slow in case many slots have been
1656 // defined and/or when this procedure is invoked many times.
1657 // In such cases it is preferable to use indexed addressing in the user code
1658 // either directly or via a few invokations of GetSlotIndex().
1660 // In case the pointer argument is zero, indeed a value of zero will be
1661 // stored at the first free position of the specified slotname.
1663 // In principle any object derived from TObject can be referred to by this
1665 // However, this "linking back" facility was introduced to enable AliSignal slots
1666 // to refer directly to the various AliTracks to which the AliSignal object itself
1667 // is related (see AliTrack::AddSignal).
1668 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1669 // object, the current signal is automatically related to this AliTrack
1670 // (or derived) object.
1671 // Also a global link to this AliTrack (or derived) object will be stored
1672 // via the AddTrack() facility.
1676 // In case one just wants to relate the current AliSignal to a certain AliTrack
1677 // without a specific signal slot association, it is much more efficient
1678 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1680 // Please also have a look at the docs of the memberfunction ResetLink()
1681 // to prevent the situation of stored pointers to non-existent object.
1683 Int_t j=GetSlotIndex(name);
1684 if (j>0) AddLink(obj,j);
1686 ///////////////////////////////////////////////////////////////////////////
1687 void AliSignal::ResetLink(Int_t j,Int_t k)
1689 // Reset the link of the j-th slot at position k.
1692 // The first slot is at j=1 and the first position is at k=1.
1693 // j=1 and k=1 are the default values.
1695 // This memberfunction is intended to reset only 1 specified link location.
1696 // For extended functionality, please refer to the memberfuction ResetLinks().
1698 // In general the user should take care of properly clearing the corresponding
1699 // pointer here when the referred object is deleted.
1700 // However, this "linking back" facility was introduced to enable AliSignal slots
1701 // to refer directly to the various AliTracks to which the AliSignal object itself
1702 // is related (see AliTrack::AddSignal).
1703 // As such, the AliTrack destructor already takes care of clearing the corresponding
1704 // links from the various AliSignal slots for all the AliSignal objects that were
1705 // related to that AliTrack.
1706 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1707 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1708 // the AliSignal object when the corresponding AliTrack object is deleted.
1710 // Note : In the internal storage matrix slots=columns positions=rows
1711 if (fLinks) fLinks->RemoveObject(k,j);
1713 ///////////////////////////////////////////////////////////////////////////
1714 void AliSignal::ResetLink(TString name,Int_t k)
1716 // Reset the link of the name-specified slot at position k.
1718 // This memberfunction is intended to reset only 1 specified link location.
1719 // For extended functionality, please refer to the memberfuction ResetLinks().
1721 // This procedure involves a slot-index search based on the specified name
1722 // at each invokation. This may become slow in case many slots have been
1723 // defined and/or when this procedure is invoked many times.
1724 // In such cases it is preferable to use indexed addressing in the user code
1725 // either directly or via a few invokations of GetSlotIndex().
1727 Int_t j=GetSlotIndex(name);
1728 if (j>0) ResetLink(j,k);
1730 ///////////////////////////////////////////////////////////////////////////
1731 void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k)
1733 // Reset single or multiple slot link(s) according to user specified selections.
1737 // This facility only acts on the slot related links.
1738 // The global track reference list will not be affected.
1739 // To remove all references to AliTrack (or derived) objects, please
1740 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1742 // A link is only reset if the stored reference matches the argument "obj".
1743 // In case obj=0 no check on the matching of the stored reference is performed
1744 // and the stored link is always reset in accordance with the other
1745 // selection criteria.
1747 // In case the slot argument "j" is specified, only the links from that
1748 // specified slot will be deleted.
1749 // In case j=0 (default) no checking on the slot index is performed.
1751 // In case the position argument "k" is specified, only the links from that
1752 // specified position will be deleted.
1753 // In case k=0 (default) no checking on the position index is performed.
1755 // So, invokation of ResetLinks(obj) will remove all references to the
1756 // object "obj" from the total AliSignal, whereas ResetLinks(obj,j)
1757 // will remove all references to the object "obj" only from slot "j".
1761 // The first slot is indicated as j=1, whereas the first position is at k=1.
1763 // Invokation of ResetLinks(0,row,col) is equivalent to invoking the
1764 // memberfunction ResetLink(row,col).
1765 // Invoking the latter directly is slightly faster.
1767 // Invokation of ResetLinks(0) will reset all stored references in this AliSignal.
1769 // In general the user should take care of properly clearing the corresponding
1770 // pointer here when the referred object is deleted.
1771 // However, this "linking back" facility was introduced to enable AliSignal slots
1772 // to refer directly to the various AliTracks to which the AliSignal object itself
1773 // is related (see AliTrack::AddSignal).
1774 // As such, the AliTrack destructor already takes care of clearing the corresponding
1775 // links from the various AliSignal slots for all the AliSignal objects that were
1776 // related to that AliTrack.
1777 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1778 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1779 // the AliSignal object when the corresponding AliTrack object is deleted.
1781 if (!fLinks) return;
1783 if (!obj && !j && !k)
1789 // Note : In the internal storage matrix slots=columns positions=rows
1790 fLinks->RemoveObjects(obj,k,j);
1793 ///////////////////////////////////////////////////////////////////////////
1794 void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k)
1796 // Reset single or multiple slot link(s) according to user specified selections.
1800 // This facility only acts on the slot related links.
1801 // The global track reference list will not be affected.
1802 // To remove all references to AliTrack (or derived) objects, please
1803 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1805 // A link is only reset if the stored reference matches the argument "obj".
1806 // In case obj=0 no check on the matching of the stored reference is performed
1807 // and the stored link is always reset in accordance with the other
1808 // selection criteria.
1810 // In case the position argument "k" is specified, only the links from that
1811 // specified position will be deleted.
1812 // In case k=0 (default) no checking on the position index is performed.
1814 // This procedure involves a slot-index search based on the specified name
1815 // at each invokation. This may become slow in case many slots have been
1816 // defined and/or when this procedure is invoked many times.
1817 // In such cases it is preferable to use indexed addressing in the user code
1818 // either directly or via a few invokations of GetSlotIndex().
1820 // In general the user should take care of properly clearing the corresponding
1821 // pointer here when the referred object is deleted.
1822 // However, this "linking back" facility was introduced to enable AliSignal slots
1823 // to refer directly to the various AliTracks to which the AliSignal object itself
1824 // is related (see AliTrack::AddSignal).
1825 // As such, the AliTrack destructor already takes care of clearing the corresponding
1826 // links from the various AliSignal slots for all the AliSignal objects that were
1827 // related to that AliTrack.
1828 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1829 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1830 // the AliSignal object when the corresponding AliTrack object is deleted.
1832 Int_t j=GetSlotIndex(name);
1833 if (j>0) ResetLinks(obj,j,k);
1835 ///////////////////////////////////////////////////////////////////////////
1836 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const
1838 // Provide the slot and position indices of all the storage locations
1839 // of the specified object.
1840 // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays
1841 // from which the (j,k) pairs can be obtained from the corresponding
1842 // array indices like (j,k)=(js.At(i),ks.At(i)).
1843 // The integer return argument represents the number of (j,k) pairs which
1844 // were encountered for the specified object.
1846 // If obj=0 no object selection is performed and all (j,k) indices
1847 // of the stored references for all objects are returned.
1851 // As usual the convention is that slot and position numbering starts at 1.
1853 // This memberfunction always resets the two TArrayI arrays at the start.
1855 // This memberfunction can only be used to obtain the (j,k) indices
1856 // of the object as stored via the SetLink() or AddLink() memberfunction.
1857 // This means that in case the user has entered a TObjArray as object
1858 // (to increase the dimension of the resulting structure), the (j,k)
1859 // indices of that TObjArray are obtained and NOT the indices of the
1860 // actual objects contained in that TObjArray structure.
1865 // Note : In the internal storage matrix slots=columns positions=rows
1866 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js);
1869 ///////////////////////////////////////////////////////////////////////////
1870 Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const
1872 // Provide the position indices of all the storage locations of the
1873 // specified object in the j-th slot of this AliSignal.
1874 // The position indices are returned in the TArrayI array.
1875 // The integer return argument represents the number of storage locations which
1876 // were encountered for the specified object in the j-th slot.
1878 // If obj=0 no object selection is performed and all position indices
1879 // of the stored references for all objects of the j-th slot are returned.
1881 // If j=0 all slots will be scanned and all position indices matching the
1882 // object selection are returned.
1883 // Note that in this case multiple appearances of the same position index
1884 // will only be recorded once in the returned TArrayI array.
1888 // As usual the convention is that slot and position numbering starts at 1.
1890 // This memberfunction always resets the TArrayI array at the start.
1892 // This memberfunction can only be used to obtain the position indices
1893 // of the object as stored via the SetLink() or AddLink() memberfunction.
1894 // This means that in case the user has entered a TObjArray as object
1895 // (to increase the dimension of the resulting structure), the position
1896 // indices of that TObjArray are obtained and NOT the indices of the
1897 // actual objects contained in that TObjArray structure.
1901 // Note : In the internal storage matrix slots=columns positions=rows
1902 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j);
1905 ///////////////////////////////////////////////////////////////////////////
1906 Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const
1908 // Provide the position indices of all the storage locations of the
1909 // specified object in the name-specified slot of this AliSignal.
1910 // The position indices are returned in the TArrayI array.
1911 // The integer return argument represents the number of storage locations which
1912 // were encountered for the specified object in the j-th slot.
1914 // If obj=0 no object selection is performed and all position indices
1915 // of the stored references for all objects of the j-th slot are returned.
1917 // This procedure involves a slot-index search based on the specified name
1918 // at each invokation. This may become slow in case many slots have been
1919 // defined and/or when this procedure is invoked many times.
1920 // In such cases it is preferable to use indexed addressing in the user code
1921 // either directly or via a few invokations of GetSlotIndex().
1923 Int_t j=GetSlotIndex(name);
1925 if (j>0) n=GetIndices(obj,j,ks);
1928 ///////////////////////////////////////////////////////////////////////////
1929 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const
1931 // Provide the slot indices of all the storage locations of the
1932 // specified object for the k-th position in this AliSignal.
1933 // The slot indices are returned in the TArrayI array.
1934 // The integer return argument represents the number of storage locations which
1935 // were encountered for the specified object in the k-th position.
1937 // If obj=0 no object selection is performed and all slot indices
1938 // of the stored references for all objects in the k-th position are returned.
1940 // If k=0 all positions will be scanned and all slot indices matching the
1941 // object selection are returned.
1942 // Note that in this case multiple appearances of the same slot index
1943 // will only be recorded once in the returned TArrayI array.
1947 // As usual the convention is that slot and position numbering starts at 1.
1949 // This memberfunction always resets the TArrayI array at the start.
1951 // This memberfunction can only be used to obtain the slot indices
1952 // of the object as stored via the SetLink() or AddLink() memberfunction.
1953 // This means that in case the user has entered a TObjArray as object
1954 // (to increase the dimension of the resulting structure), the slot
1955 // indices of that TObjArray are obtained and NOT the indices of the
1956 // actual objects contained in that TObjArray structure.
1960 // Note : In the internal storage matrix slots=columns positions=rows
1961 if (fLinks) nrefs=fLinks->GetIndices(obj,k,js);
1964 ///////////////////////////////////////////////////////////////////////////
1965 void AliSignal::SetSwapMode(Int_t swap)
1967 // Set swapmode flag for the internal link storage.
1968 // In case for the stored links the maximum slot number differs considerably
1969 // from the maximum position number, it might be more efficient
1970 // (w.r.t. memory usage and/or output file size) to internally store the
1971 // link reference matrix with the rows and colums swapped.
1972 // This swapping is only related with the internal storage and as such
1973 // is completely hidden for the user.
1974 // At invokation of this memberfunction the default argument is swap=1.
1976 // Note : The swap mode can only be set as long as no links are
1977 // stored in the AliSignal (i.e. a new instance of AliSignal
1978 // or after invokation of the Reset() or ResetLinks() function).
1980 if (!fLinks) fLinks=new AliObjMatrix();
1981 fLinks->SetSwapMode(swap);
1983 ///////////////////////////////////////////////////////////////////////////
1984 Int_t AliSignal::GetSwapMode() const
1986 // Provide swapmode flag of the link storage.
1988 if (fLinks) swap=fLinks->GetSwapMode();
1991 ///////////////////////////////////////////////////////////////////////////
1992 void AliSignal::SetDevice(TObject* dev)
1994 // Store the pointer to the device which owns this AliSignal object.
1995 // This memberfunction is meant for internal use in AliDevice.
1998 ///////////////////////////////////////////////////////////////////////////
1999 AliDevice* AliSignal::GetDevice() const
2001 // Provide the pointer to the device which owns this AliSignal object.
2002 return (AliDevice*)fDevice;
2004 ///////////////////////////////////////////////////////////////////////////
2005 void AliSignal::AddTrack(AliTrack& t,Int_t mode)
2007 // Relate an AliTrack object to this signal.
2008 // Only the pointer values are stored for (backward) reference, meaning
2009 // that the tracks of which the pointers are stored are NOT owned
2010 // by the AliSignal object.
2012 // mode = 0 : Only the reference to the specified track is stored in
2013 // the current signal, without storing the (backward) reference
2014 // to this signal into the AliTrack structure.
2015 // 1 : The (backward) reference to the current signal is also automatically
2016 // stored into the AliTrack (or derived) object specified in the
2019 // The default is mode=1.
2021 if (!fTracks) fTracks=new TObjArray(1);
2023 // Check if this track is already stored for this signal
2024 Int_t ntk=GetNtracks();
2025 for (Int_t i=0; i<ntk; i++)
2027 if (&t==fTracks->At(i)) return;
2031 if (mode==1) t.AddSignal(*this,0);
2033 ///////////////////////////////////////////////////////////////////////////
2034 void AliSignal::RemoveTrack(AliTrack& t,Int_t mode)
2036 // Remove related AliTrack object from this signal.
2037 // Also all references (if any) to this track in the slot links area
2040 // mode = 0 : All references to the specified track are removed from
2041 // the current signal, without removing the (backward) reference
2042 // to this signal from the AliTrack structure.
2043 // 1 : The (backward) reference to the current signal is also automatically
2044 // removed from the AliTrack (or derived) object specified in the
2047 // The default is mode=1.
2051 AliTrack* test=(AliTrack*)fTracks->Remove(&t);
2052 if (test) fTracks->Compress();
2057 if (mode==1) t.RemoveSignal(*this,0);
2059 ///////////////////////////////////////////////////////////////////////////
2060 void AliSignal::RemoveTracks(Int_t mode)
2062 // Remove all related AliTrack objects from this signal.
2063 // Also all references (if any) to the related tracks in the slot links area
2066 // mode = 0 : All track references are removed from the current signal,
2067 // without removing the (backward) references to this signal from
2068 // the corresponding AliTrack objects.
2069 // 1 : The (backward) references to the current signal are also automatically
2070 // removed from the corresponding AliTrack (or derived) objects.
2072 // The default is mode=1.
2074 if (!fTracks) return;
2076 Int_t ntk=GetNtracks();
2077 for (Int_t i=0; i<ntk; i++)
2079 AliTrack* tx=(AliTrack*)fTracks->At(i);
2083 if (mode==1) tx->RemoveSignal(*this,0);
2090 ///////////////////////////////////////////////////////////////////////////
2091 Int_t AliSignal::GetNtracks(AliTrack* t) const
2093 // Provide the number of related AliTracks.
2094 // In case an AliTrack pointer is specified as input argument,
2095 // the number returned will be the number of occurrences (i.e. 0 or 1)
2096 // for that specified track.
2097 // By default t=0, which implies that just the number of all associated
2098 // tracks will be returned.
2100 if (!fTracks) return 0;
2102 Int_t ntk=fTracks->GetEntries();
2106 for (Int_t i=0; i<ntk; i++)
2108 AliTrack* tx=(AliTrack*)fTracks->At(i);
2109 if (tx==t) return 1;
2114 ///////////////////////////////////////////////////////////////////////////
2115 AliTrack* AliSignal::GetTrack(Int_t j) const
2117 // Provide the related AliTrack number j.
2118 // Note : j=1 denotes the first track.
2120 if (!fTracks) return 0;
2122 if ((j >= 1) && (j <= GetNtracks()))
2124 return (AliTrack*)fTracks->At(j-1);
2128 cout << " *AliSignal* track number : " << j << " out of range."
2129 << " Ntk = " << GetNtracks() << endl;
2133 ///////////////////////////////////////////////////////////////////////////
2134 AliTrack* AliSignal::GetIdTrack(Int_t id) const
2136 // Return the track with user identifier "id" of this signal
2137 if (!fTracks) return 0;
2140 for (Int_t i=0; i<GetNtracks(); i++)
2142 tx=(AliTrack*)fTracks->At(i);
2143 if (id == tx->GetId()) return tx;
2145 return 0; // No matching id found
2147 ///////////////////////////////////////////////////////////////////////////
2148 TObject* AliSignal::Clone(const char* name) const
2150 // Make a deep copy of the current object and provide the pointer to the copy.
2151 // This memberfunction enables automatic creation of new objects of the
2152 // correct type depending on the object type, a feature which may be very useful
2153 // for containers when adding objects in case the container owns the objects.
2154 // This feature allows e.g. AliTrack to store either AliSignal objects or
2155 // objects derived from AliSignal via the AddSignal memberfunction, provided
2156 // these derived classes also have a proper Clone memberfunction.
2158 AliSignal* sig=new AliSignal(*this);
2161 if (strlen(name)) sig->SetName(name);
2165 ///////////////////////////////////////////////////////////////////////////