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.
131 ///////////////////////////////////////////////////////////////////////////
132 AliSignal::~AliSignal()
134 // Destructor to delete dynamically allocated memory
157 // Remove this signal from all related tracks
158 for (Int_t i=1; i<=GetNtracks(); i++)
160 AliTrack* tx=GetTrack(i);
161 if (tx) tx->RemoveSignal(*this,0);
167 ///////////////////////////////////////////////////////////////////////////
168 AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s)
177 // Don't copy the owning device pointer for the copy
180 Int_t n=s.GetNvalues();
182 for (Int_t i=1; i<=n; i++)
189 for (Int_t j=1; j<=n; j++)
191 val=s.GetSignalError(j);
192 SetSignalError(val,j);
196 for (Int_t k=1; k<=n; k++)
198 TH1F* hist=s.GetWaveform(k);
199 if (hist) SetWaveform(hist,k);
205 n=s.GetIndices(dum,slotarr,posarr);
207 for (Int_t idx=0; idx<n; idx++)
209 slot=slotarr.At(idx);
211 TObject* obj=s.GetLink(slot,pos);
212 if (obj) SetLink(obj,slot,pos);
215 Int_t ntk=s.GetNtracks();
218 fTracks=new TObjArray(ntk);
219 for (Int_t it=1; it<=ntk; it++)
221 AliTrack* tx=s.GetTrack(it);
226 ///////////////////////////////////////////////////////////////////////////
227 void AliSignal::Reset(Int_t mode)
229 // Reset all signal and position values and errors to 0.
231 // mode = 0 Reset position and all signal values and their errors to 0.
232 // The waveform histograms are reset, but the calibration
233 // constants (i.e. gains and offsets) are kept.
234 // 1 Reset position and delete the signal and error storage arrays.
235 // Also the waveform histograms, gains and offset arrays are deleted.
237 // The default when invoking Reset() corresponds to mode=0.
239 // Note : In all cases the storage of the various links will be reset.
240 // The UniqueID, name and title will NOT be reset.
241 // In case the user wants to reset these attributes, this has to
242 // be done explicitly via the SET facilities.
244 // The usage of mode=0 allows to re-use the allocated memory for new
245 // signal (and error) values. This behaviour is preferable (i.e. faster)
246 // in case the various signals always contain the same number of values
247 // and have the same calibration constants.
248 // The usage of mode=1 is slower, but allows a more efficient memory
249 // occupation (and smaller output file size) in case the different
250 // signals have a variable number of values.
252 // For more specific actions see ResetPosition(), ResetSignals(),
253 // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(),
254 // DeleteWaveform() and DeleteCalibrations().
257 if (mode<0 || mode>1)
259 cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl;
260 cout << " Default mode=0 will be used." << endl;
272 DeleteCalibrations();
275 if (fLinks) fLinks->Reset();
284 ///////////////////////////////////////////////////////////////////////////
285 void AliSignal::ResetSignals(Int_t mode)
287 // Reset various signal data according to user selection.
289 // mode = 0 Reset all signal values and their errors to 0.
290 // 1 Reset only signal values
291 // 2 Reset only signal errors
293 // The default when invoking ResetSignals() corresponds to mode=0.
295 // Irrespective of the mode, the waveform histograms are reset.
297 if (mode<0 || mode>2)
299 cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl;
300 cout << " Default mode=0 will be used." << endl;
304 if (fSignals && (mode==0 || mode==1))
306 for (Int_t i=0; i<fSignals->GetSize(); i++)
308 fSignals->AddAt(0,i);
312 if (fDsignals && (mode==0 || mode==2))
314 for (Int_t j=0; j<fDsignals->GetSize(); j++)
316 fDsignals->AddAt(0,j);
322 ///////////////////////////////////////////////////////////////////////////
323 void AliSignal::DeleteSignals(Int_t mode)
325 // Delete storage arrays of various signal data according to user selection.
327 // mode = 0 Delete arrays of both signal values and their errors.
328 // 1 Delete only signal values array
329 // 2 Delete only signal errors array
331 // The default when invoking DeleteSignals() corresponds to mode=0.
333 // Irrespective of the mode, the waveform histograms are deleted.
335 if (mode<0 || mode>2)
337 cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl;
338 cout << " Default mode=0 will be used." << endl;
342 if (fSignals && (mode==0 || mode==1))
348 if (fDsignals && (mode==0 || mode==2))
356 ///////////////////////////////////////////////////////////////////////////
357 void AliSignal::SetSignal(Double_t sig,Int_t j)
359 // Store signal value for the j-th (default j=1) slot.
360 // Note : The first signal slot is at j=1.
361 // In case the value of the index j exceeds the maximum number of reserved
362 // slots for signal values, the number of reserved slots for the
363 // signal values is increased automatically.
367 fSignals=new TArrayF(j);
371 Int_t size=fSignals->GetSize();
378 fSignals->AddAt(float(sig),j-1);
380 ///////////////////////////////////////////////////////////////////////////
381 void AliSignal::SetSignal(Double_t sig,TString name)
383 // Store signal value for the name-specified slot.
385 // This procedure involves a slot-index search based on the specified name
386 // at each invokation. This may become slow in case many slots have been
387 // defined and/or when this procedure is invoked many times.
388 // In such cases it is preferable to use indexed addressing in the user code
389 // either directly or via a few invokations of GetSlotIndex().
391 Int_t j=GetSlotIndex(name);
392 if (j>0) SetSignal(sig,j);
394 ///////////////////////////////////////////////////////////////////////////
395 void AliSignal::AddSignal(Double_t sig,Int_t j)
397 // Add value to the signal of the j-th (default j=1) slot.
398 // Note : The first signal slot is at j=1.
399 // In case the value of the index j exceeds the maximum number of reserved
400 // slots for signal values, the number of reserved slots for the
401 // signal values is increased automatically.
405 fSignals=new TArrayF(j);
409 Int_t size=fSignals->GetSize();
416 Float_t sum=(fSignals->At(j-1))+sig;
417 fSignals->AddAt(sum,j-1);
419 ///////////////////////////////////////////////////////////////////////////
420 void AliSignal::AddSignal(Double_t sig,TString name)
422 // Add value to the signal of the name-specified slot.
424 // This procedure involves a slot-index search based on the specified name
425 // at each invokation. This may become slow in case many slots have been
426 // defined and/or when this procedure is invoked many times.
427 // In such cases it is preferable to use indexed addressing in the user code
428 // either directly or via a few invokations of GetSlotIndex().
430 Int_t j=GetSlotIndex(name);
431 if (j>0) AddSignal(sig,j);
433 ///////////////////////////////////////////////////////////////////////////
434 Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const
436 // Provide signal value of the j-th (default j=1) slot.
437 // Note : The first signal slot is at j=1.
438 // In case no signal is present or the input argument "j" or "mode" is invalid,
439 // the value 0 is returned.
440 // The parameter "mode" allows for automatic (de)calibration of the signal
441 // (e.g. gain etc... correction or via explicit (de)calibration functions).
443 // mode = 0 : Just the j-th signal is returned.
444 // 1 : The j-th signal is corrected for the gain, offset, dead flag etc...
445 // In case the j-th slot was marked dead, 0 is returned.
446 // In case the gain value was not set, gain=1 will be assumed.
447 // In case the gain value was 0, a signal value of 0 is returned.
448 // In case the offset value was not set, offset=0 will be assumed.
449 // 2 : Same as mode=1 but gain, offset dead flag etc... are taken from
450 // the AliDevice which owns this AliSignal object.
451 // The corresponding AliDevice slot is obtained via matching of
452 // the slotnames. In case this fails, the slotindex "j" of the
453 // input argument will be used.
454 // In case this AliSignal object has no parent AliDevice, just
455 // the j-th signal is returned (like with mode=0).
456 // 3 : The j-th signal is corrected using the corresponding calibration
458 // In case the j-th slot was marked dead, 0 is returned.
459 // In case no calibration function is present, just the j-th signal
460 // is returned (like with mode=0).
461 // 4 : Same as mode=3 but the calibration function and dead flag are
462 // taken from the AliDevice which owns this AliSignal object.
463 // The corresponding AliDevice slot is obtained via matching of
464 // the slotnames. In case this fails, the slotindex "j" of the
465 // input argument will be used.
466 // 5 : Same as mode=2 but in case no parent AliDevice is present
467 // an automatic switch to mode=1 will be made.
468 // 6 : Same as mode=4 but in case no parent AliDevice is present
469 // an automatic switch to mode=3 will be made.
470 // 7 : Same as mode=3 but in case no calibration function is present
471 // an automatic switch to mode=4 will be made.
472 // 8 : Same as mode=7 but also the corresponding dead flag of the
473 // parent device (if any) will be checked.
474 // If either the dead flag of the requested signal slot of this
475 // AliSignal object or the corresponding parent device slot is
476 // set, 0 is returned.
478 // <0 : The corresponding de-correction or de-calibration is performed
480 // The corrected signal (sigc) is determined as follows :
482 // sigc=(signal/gain)-offset
484 // The de-corrected signal is determined as follows :
486 // signal=(sigc+offset)*gain
488 // The default is mode=0.
490 if (abs(mode)>8) return 0;
497 // Get the corresponding slot index (and dead flag) of the parent device
500 AliSignal* parent=(AliSignal*)GetDevice();
501 if ((abs(mode)==2 || abs(mode)>=4) && parent)
503 TString name=GetSlotName(j);
504 if (strlen(name.Data())) pj=parent->GetSlotIndex(name);
505 if (abs(mode)==8 && pj) pdead=parent->GetDeadValue(pj);
508 if (mode==-8) mode=-7;
510 AliSignal* sx=(AliSignal*)this;
515 f=sx->GetCalFunction(jcal);
527 f=sx->GetDecalFunction(jcal);
538 if (abs(mode)==2 || abs(mode)>=4)
540 sx=(AliSignal*)GetDevice();
543 if (!sx && abs(mode)>=5) sx=(AliSignal*)this;
545 if (mode==-5) mode=-2;
547 if (mode==-6) mode=-3;
551 if (j>0 && j<=(fSignals->GetSize()))
553 sig=fSignals->At(j-1);
555 if (mode==0 || !sx) return sig;
557 // Check for the dead flag setting
558 if (sx->GetDeadValue(jcal) || pdead) return 0;
560 // (De)correct the signal for the gain and offset
561 if (abs(mode)==1 || abs(mode)==2)
563 if (sx->GetGainFlag(jcal)) gain=sx->GetGain(jcal);
564 if (sx->GetOffsetFlag(jcal)) offset=sx->GetOffset(jcal);
568 if (mode>0) sig=(sig/gain)-offset; // Gain and offset correction
569 if (mode<0) sig=(sig+offset)*gain; // Gain and offset de-correction
578 // (De)calibrate the signal with the corresponding (de)calibration function
579 if (abs(mode)==3 || abs(mode)==4)
581 f=sx->GetCalFunction(jcal);
582 if (mode<0) f=sx->GetDecalFunction(jcal);
583 if (f) sig=f->Eval(sig);
589 cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl;
594 ///////////////////////////////////////////////////////////////////////////
595 Float_t AliSignal::GetSignal(TString name,Int_t mode) const
597 // Provide signal value of the name-specified slot.
598 // In case no signal is present, 0 is returned.
599 // The parameter "mode" allows for automatic (de)calibration of the signal
600 // (e.g. gain etc... correction or via explicit (de)calibration functions).
601 // For further details about the (de)calibration modes, please refer to the
602 // corresponding slot-index based memberfunction.
604 // The default is mode=0.
606 // This procedure involves a slot-index search based on the specified name
607 // at each invokation. This may become slow in case many slots have been
608 // defined and/or when this procedure is invoked many times.
609 // In such cases it is preferable to use indexed addressing in the user code
610 // either directly or via a few invokations of GetSlotIndex().
612 Int_t j=GetSlotIndex(name);
614 if (j>0) val=GetSignal(j,mode);
617 ///////////////////////////////////////////////////////////////////////////
618 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
620 // Store error on the signal for the j-th (default j=1) slot.
621 // Note : The first signal slot is at j=1.
622 // In case the value of the index j exceeds the maximum number of reserved
623 // slots for signal error values, the number of reserved slots for the
624 // signal errors is increased automatically.
628 fDsignals=new TArrayF(j);
632 Int_t size=fDsignals->GetSize();
639 fDsignals->AddAt(float(dsig),j-1);
641 ///////////////////////////////////////////////////////////////////////////
642 void AliSignal::SetSignalError(Double_t dsig,TString name)
644 // Store error on the signal for the name-specified slot.
646 // This procedure involves a slot-index search based on the specified name
647 // at each invokation. This may become slow in case many slots have been
648 // defined and/or when this procedure is invoked many times.
649 // In such cases it is preferable to use indexed addressing in the user code
650 // either directly or via a few invokations of GetSlotIndex().
652 Int_t j=GetSlotIndex(name);
653 if (j>0) SetSignalError(dsig,j);
655 ///////////////////////////////////////////////////////////////////////////
656 Float_t AliSignal::GetSignalError(Int_t j) const
658 // Provide error on the signal of the j-th (default j=1) slot.
659 // Note : The first signal slot is at j=1.
660 // In case no signal is present or the argument j is invalid, 0 is returned.
664 if (j>0 && j<=(fDsignals->GetSize()))
666 err=fDsignals->At(j-1);
670 cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl;
675 ///////////////////////////////////////////////////////////////////////////
676 Float_t AliSignal::GetSignalError(TString name) const
678 // Provide error on the signal of the name-specified slot.
680 // This procedure involves a slot-index search based on the specified name
681 // at each invokation. This may become slow in case many slots have been
682 // defined and/or when this procedure is invoked many times.
683 // In such cases it is preferable to use indexed addressing in the user code
684 // either directly or via a few invokations of GetSlotIndex().
686 Int_t j=GetSlotIndex(name);
688 if (j>0) val=GetSignalError(j);
691 ///////////////////////////////////////////////////////////////////////////
692 void AliSignal::Data(TString f,TString u) const
694 // Provide all signal information within the coordinate frame f.
696 // The string argument "u" allows to choose between different angular units
697 // in case e.g. a spherical frame is selected.
698 // u = "rad" : angles provided in radians
699 // "deg" : angles provided in degrees
701 // The defaults are f="car" and u="rad".
703 const char* name=GetName();
704 const char* title=GetTitle();
706 cout << " *" << ClassName() << "::Data* Id : " << GetUniqueID();
707 if (strlen(name)) cout << " Name : " << name;
708 if (strlen(title)) cout << " Title : " << title;
711 AliPosition::Data(f,u);
714 const char* devname=fDevice->GetName();
715 const char* devtitle=fDevice->GetTitle();
716 cout << " Owned by device : " << fDevice->ClassName()
717 << " Id : " << fDevice->GetUniqueID();
718 if (strlen(devname)) cout << " Name : " << devname;
719 if (strlen(devtitle)) cout << " Title : " << devtitle;
723 // Provide an overview of the stored waveforms
726 // Provide an overview of the associated tracks
729 // Provide an overview of all the data and attribute slots
732 ///////////////////////////////////////////////////////////////////////////
733 void AliSignal::List(Int_t j) const
735 // Provide signal information for the j-th slot.
736 // The first slot is at j=1.
737 // In case j=0 (default) the data of all slots will be listed.
738 // In case j=-1 the data of all slots will be listed, but the header
739 // information will be suppressed.
743 cout << " *AliSignal::List* Invalid argument j = " << j << endl;
749 const char* name=GetName();
750 const char* title=GetTitle();
752 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
753 if (strlen(name)) cout << " Name : " << name;
754 if (strlen(title)) cout << " Title : " << title;
758 const char* devname=fDevice->GetName();
759 const char* devtitle=fDevice->GetTitle();
760 cout << " Owned by device : " << fDevice->ClassName();
761 if (strlen(devname)) cout << " Name : " << devname;
762 if (strlen(devtitle)) cout << " Title : " << devtitle;
767 Int_t nvalues=GetNvalues();
768 Int_t nerrors=GetNerrors();
770 if (GetNlinks()) nlinkslots=fLinks->GetMaxColumn();
771 Int_t ncalibs=GetNcalflags();
772 Int_t ncalfuncs=GetNcalfuncs();
773 Int_t ndecalfuncs=GetNdecalfuncs();
776 if (nerrors>n) n=nerrors;
777 if (nlinkslots>n) n=nlinkslots;
778 if (InheritsFrom("AliDevice"))
780 if (ncalibs>n) n=ncalibs;
781 if (ncalfuncs>n) n=ncalfuncs;
782 if (ndecalfuncs>n) n=ndecalfuncs;
792 for (Int_t i=1; i<=n; i++)
794 cout << " Slot : " << i;
795 if (i<=nvalues) cout << " Signal value : " << GetSignal(i);
796 if (i<=nerrors) cout << " error : " << GetSignalError(i);
800 nrefs=GetIndices(obj,i,posarr);
801 for (Int_t k=0; k<nrefs; k++)
807 cout << " Link at position " << pos << " to : " << obj->ClassName();
808 if (obj->InheritsFrom("TNamed"))
810 const char* lname=obj->GetName();
811 const char* ltitle=obj->GetTitle();
812 if (strlen(lname)) cout << " Name : " << lname;
813 if (strlen(ltitle)) cout << " Title : " << ltitle;
824 cout << " Slot : " << j;
825 if (j<=nvalues) cout << " Signal value : " << GetSignal(j);
826 if (j<=nerrors) cout << " error : " << GetSignalError(j);
830 nrefs=GetIndices(obj,j,posarr);
831 for (Int_t kj=0; kj<nrefs; kj++)
837 cout << " Link at position " << pos << " to : " << obj->ClassName();
838 if (obj->InheritsFrom("TNamed"))
840 const char* lnamej=obj->GetName();
841 const char* ltitlej=obj->GetTitle();
842 if (strlen(lnamej)) cout << " Name : " << lnamej;
843 if (strlen(ltitlej)) cout << " Title : " << ltitlej;
851 ///////////////////////////////////////////////////////////////////////////
852 void AliSignal::List(TString name) const
854 // Provide signal information for the name-specified slot.
856 // This procedure involves a slot-index search based on the specified name
857 // at each invokation. This may become slow in case many slots have been
858 // defined and/or when this procedure is invoked many times.
859 // In such cases it is preferable to use indexed addressing in the user code
860 // either directly or via a few invokations of GetSlotIndex().
862 Int_t j=GetSlotIndex(name);
865 ///////////////////////////////////////////////////////////////////////////
866 void AliSignal::ListWaveform(Int_t j) const
868 // Provide information for the j-th waveform.
869 // The first waveform is at j=1.
870 // In case j=0 (default) the info of all waveforms will be listed.
871 // In case j=-1 the info of all waveforms will be listed, but the header
872 // information will be suppressed.
876 cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl;
882 const char* name=GetName();
883 const char* title=GetTitle();
885 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
886 if (strlen(name)) cout << " Name : " << name;
887 if (strlen(title)) cout << " Title : " << title;
891 const char* devname=fDevice->GetName();
892 const char* devtitle=fDevice->GetTitle();
893 cout << " Owned by device : " << fDevice->ClassName();
894 if (strlen(devname)) cout << " Name : " << devname;
895 if (strlen(devtitle)) cout << " Title : " << devtitle;
900 Int_t n=GetNwaveforms();
905 for (Int_t i=1; i<=n; i++)
910 const char* wfname=obj->GetName();
911 const char* wftitle=obj->GetTitle();
912 cout << " Waveform " << i << " : " << obj->ClassName();
913 if (strlen(wfname)) cout << " Name : " << wfname;
914 if (strlen(wftitle)) cout << " Title : " << wftitle;
926 const char* wfnamej=obj->GetName();
927 const char* wftitlej=obj->GetTitle();
928 cout << " Waveform " << j << " : " << obj->ClassName();
929 if (strlen(wfnamej)) cout << " Name : " << wfnamej;
930 if (strlen(wftitlej)) cout << " Title : " << wftitlej;
936 ///////////////////////////////////////////////////////////////////////////
937 void AliSignal::ListTrack(Int_t j) const
939 // Provide information for the j-th associated track.
940 // The first associated track is at j=1.
941 // In case j=0 (default) the info of all associated tracks will be listed.
942 // In case j=-1 the info of all tracks will be listed, but the header
943 // information will be suppressed.
947 cout << " *AliSignal::ListTrack* Invalid argument j = " << j << endl;
953 const char* name=GetName();
954 const char* title=GetTitle();
956 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
957 if (strlen(name)) cout << " Name : " << name;
958 if (strlen(title)) cout << " Title : " << title;
962 const char* devname=fDevice->GetName();
963 const char* devtitle=fDevice->GetTitle();
964 cout << " Owned by device : " << fDevice->ClassName();
965 if (strlen(devname)) cout << " Name : " << devname;
966 if (strlen(devtitle)) cout << " Title : " << devtitle;
971 Int_t n=GetNtracks();
976 for (Int_t i=1; i<=n; i++)
981 const char* txname=tx->GetName();
982 const char* txtitle=tx->GetTitle();
983 cout << " Track " << i << " : " << tx->ClassName() << " Id : " << tx->GetId();
984 if (strlen(txname)) cout << " Name : " << txname;
985 if (strlen(txtitle)) cout << " Title : " << txtitle;
997 const char* txnamej=tx->GetName();
998 const char* txtitlej=tx->GetTitle();
999 cout << " Track " << j << " : " << tx->ClassName() << " Id : " << tx->GetId();
1000 if (strlen(txnamej)) cout << " Name : " << txnamej;
1001 if (strlen(txtitlej)) cout << " Title : " << txtitlej;
1007 ///////////////////////////////////////////////////////////////////////////
1008 Int_t AliSignal::GetNvalues() const
1010 // Provide the number of values for this signal.
1012 if (fSignals) n=fSignals->GetSize();
1015 ///////////////////////////////////////////////////////////////////////////
1016 Int_t AliSignal::GetNerrors() const
1018 // Provide the number specified errors on the values for this signal.
1020 if (fDsignals) n=fDsignals->GetSize();
1023 ///////////////////////////////////////////////////////////////////////////
1024 Int_t AliSignal::GetNwaveforms() const
1026 // Provide the number of specified waveforms for this signal.
1027 // Actually the return value is the highest index of the stored waveforms.
1028 // This allows an index dependent meaning of waveform info (e.g. waveforms
1029 // with various gain values).
1030 // So, when all waveforms are stored in consequetive positions (e.g. 1,2,3),
1031 // this memberfunction returns 3, being both the highest filled position
1032 // and the actual number of waveforms.
1033 // In case only waveforms are stored at positions 1,2,5,7 this memberfunction
1034 // returns a value 7 whereas only 4 actual waveforms are present.
1035 // This implies that when looping over the various waveform slots, one
1036 // always has to check whether the returned pointer value is non-zero
1037 // (which is a good practice anyhow).
1039 if (fWaveforms) n=fWaveforms->GetLast();
1042 ///////////////////////////////////////////////////////////////////////////
1043 TH1F* AliSignal::GetWaveform(Int_t j) const
1045 // Provide pointer to the j-th waveform histogram.
1047 if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1);
1050 ///////////////////////////////////////////////////////////////////////////
1051 TH1F* AliSignal::GetWaveform(TString name) const
1053 // Provide pointer to the waveform histogram with the specified name.
1054 // In case no match is found, zero is returned.
1055 Int_t n=GetNwaveforms();
1057 for (Int_t i=1; i<=n; i++)
1059 TH1F* waveform=GetWaveform(i);
1062 str=waveform->GetName();
1063 if (str == name) return waveform;
1066 return 0; // No match found
1068 ///////////////////////////////////////////////////////////////////////////
1069 Int_t AliSignal::GetWaveformIndex(TString name) const
1071 // Provide index to the waveform histogram with the specified name.
1072 // In case no match is found, zero is returned.
1073 Int_t n=GetNwaveforms();
1075 for (Int_t i=1; i<=n; i++)
1077 TH1F* waveform=GetWaveform(i);
1080 str=waveform->GetName();
1081 if (str == name) return i;
1084 return 0; // No match found
1086 ///////////////////////////////////////////////////////////////////////////
1087 void AliSignal::SetWaveform(TH1F* waveform,Int_t j)
1089 // Set the 1D waveform histogram for the j-th waveform.
1092 // The first waveform position at j=1.
1093 // j=1 is the default value.
1095 // In case the value of the index j exceeds the maximum number of reserved
1096 // positions for the waveforms, the number of reserved positions for the waveforms
1097 // is increased automatically.
1099 // In case the histo pointer argument has the same value as the current waveform
1100 // histogram pointer value, no action is taken since the user has already
1101 // modified the actual histogram.
1103 // In case the histo pointer argument is zero, the current waveform histogram
1104 // is deleted and the pointer set to zero.
1106 // In all other cases the current waveform histogram is deleted and a new
1107 // copy of the input histogram is created which becomes the current waveform
1114 fWaveforms=new TObjArray(j);
1115 fWaveforms->SetOwner();
1118 if (j > fWaveforms->GetSize()) fWaveforms->Expand(j);
1120 TH1F* hcur=(TH1F*)fWaveforms->At(j-1);
1121 if (waveform != hcur)
1125 fWaveforms->Remove(hcur);
1131 hcur=new TH1F(*waveform);
1132 fWaveforms->AddAt(hcur,j-1);
1136 ///////////////////////////////////////////////////////////////////////////
1137 void AliSignal::ResetWaveform(Int_t j)
1139 // Reset the histogram of the j-th (default j=1) waveform.
1140 // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s).
1141 // To actually delete the histograms from memory, use DeleteWaveform().
1142 // Notes : The first position is at j=1.
1143 // j=0 ==> All waveforms will be reset.
1145 if (!fWaveforms) return;
1147 Int_t size=fWaveforms->GetSize();
1149 if ((j>=0) && (j<=size))
1153 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1154 if (hwave) hwave->Reset();
1158 for (Int_t i=0; i<size; i++)
1160 TH1F* hwave=(TH1F*)fWaveforms->At(i);
1161 if (hwave) hwave->Reset();
1167 cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl;
1171 ///////////////////////////////////////////////////////////////////////////
1172 void AliSignal::ResetWaveform(TString name)
1174 // Reset the waveform with the specified name.
1175 Int_t j=GetWaveformIndex(name);
1176 if (j>0) ResetWaveform(j);
1178 ///////////////////////////////////////////////////////////////////////////
1179 void AliSignal::DeleteWaveform(Int_t j)
1181 // Delete the histogram of the j-th (default j=1) waveform.
1182 // Notes : The first position is at j=1.
1183 // j=0 ==> All waveforms will be deleted.
1185 if (!fWaveforms) return;
1187 Int_t size=fWaveforms->GetSize();
1189 if ((j>=0) && (j<=size))
1193 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1196 fWaveforms->Remove(hwave);
1208 cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl;
1212 ///////////////////////////////////////////////////////////////////////////
1213 void AliSignal::DeleteWaveform(TString name)
1215 // Delete the waveform with the specified name.
1216 Int_t j=GetWaveformIndex(name);
1217 if (j>0) DeleteWaveform(j);
1219 ///////////////////////////////////////////////////////////////////////////
1220 Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const
1222 // Provide the number of links to the specified object for the j-th slot.
1223 // If j=0 (default) all slots will be scanned for the specified object.
1224 // If obj=0 (default) all encountered objects for the specified slot will be counted.
1225 // So, invokation of the default GetNlinks() will return the total number of
1226 // all references to all sorts of stored objects.
1229 cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl;
1233 if (!fLinks) return 0;
1238 n=fLinks->GetNrefs(obj);
1243 n=GetIndices(obj,j,posarr);
1247 ///////////////////////////////////////////////////////////////////////////
1248 Int_t AliSignal::GetNlinks(TObject* obj,TString name) const
1250 // Provide the number of links to the specified object for the name-spec. slot.
1251 // If obj=0 all encountered objects for the specified slot will be counted.
1253 // This procedure involves a slot-index search based on the specified name
1254 // at each invokation. This may become slow in case many slots have been
1255 // defined and/or when this procedure is invoked many times.
1256 // In such cases it is preferable to use indexed addressing in the user code
1257 // either directly or via a few invokations of GetSlotIndex().
1259 Int_t j=GetSlotIndex(name);
1261 if (j>0) n=GetNlinks(obj,j);
1264 ///////////////////////////////////////////////////////////////////////////
1265 TObject* AliSignal::GetLink(Int_t j,Int_t k) const
1267 // Provide pointer of the object linked to the j-th slot at position k.
1270 // Note : In the internal storage matrix slots=columns positions=rows
1271 if (fLinks) obj=fLinks->GetObject(k,j);
1274 ///////////////////////////////////////////////////////////////////////////
1275 TObject* AliSignal::GetLink(TString name,Int_t k) const
1277 // Provide pointer of the object linked to the name-spec. slot at position k.
1279 // This procedure involves a slot-index search based on the specified name
1280 // at each invokation. This may become slow in case many slots have been
1281 // defined and/or when this procedure is invoked many times.
1282 // In such cases it is preferable to use indexed addressing in the user code
1283 // either directly or via a few invokations of GetSlotIndex().
1285 Int_t j=GetSlotIndex(name);
1287 if (j>0) obj=GetLink(j,k);
1290 ///////////////////////////////////////////////////////////////////////////
1291 void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k)
1293 // Introduce a link (=pointer) to an object for the j-th slot at position k.
1294 // Only the pointer values are stored for (backward) reference, meaning
1295 // that the objects of which the pointers are stored are NOT owned
1296 // by the AliSignal object.
1299 // The first slot is at j=1 and the first position is at k=1.
1300 // j=1 and k=1 are the default values.
1302 // If needed, the storage area for the links is increased automatically.
1304 // In case the pointer argument is zero, indeed a value of zero will be
1305 // stored at the specified position (k) for the specified slot (j).
1307 // In principle any object derived from TObject can be referred to by this
1309 // However, this "linking back" facility was introduced to enable AliSignal slots
1310 // to refer directly to the various AliTracks to which the AliSignal object itself
1311 // is related (see AliTrack::AddSignal).
1312 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1313 // object, the current signal is automatically related to this AliTrack
1314 // (or derived) object.
1315 // Also a global link to this AliTrack (or derived) object will be stored
1316 // via the AddTrack() facility.
1320 // In case one just wants to relate the current AliSignal to a certain AliTrack
1321 // without a specific signal slot association, it is much more efficient
1322 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1324 // Please also have a look at the docs of the memberfunction ResetLink()
1325 // to prevent the situation of stored pointers to non-existent object.
1327 if (!fLinks && obj) fLinks=new AliObjMatrix();
1329 if (!fLinks) return;
1331 // Note : In the internal storage matrix slots=columns positions=rows
1332 fLinks->EnterObject(k,j,obj);
1335 if (obj->InheritsFrom("AliTrack"))
1337 AliTrack* t=(AliTrack*)obj;
1342 ///////////////////////////////////////////////////////////////////////////
1343 void AliSignal::SetLink(TObject* obj,TString name,Int_t k)
1345 // Introduce a link (=pointer) to an object for the name-spec. slot at position k.
1346 // Only the pointer values are stored for (backward) reference, meaning
1347 // that the objects of which the pointers are stored are NOT owned
1348 // by the AliSignal object.
1350 // This procedure involves a slot-index search based on the specified name
1351 // at each invokation. This may become slow in case many slots have been
1352 // defined and/or when this procedure is invoked many times.
1353 // In such cases it is preferable to use indexed addressing in the user code
1354 // either directly or via a few invokations of GetSlotIndex().
1356 // In case the pointer argument is zero, indeed a value of zero will be
1357 // stored at the specified position (k) for the specified slotname.
1359 // In principle any object derived from TObject can be referred to by this
1361 // However, this "linking back" facility was introduced to enable AliSignal slots
1362 // to refer directly to the various AliTracks to which the AliSignal object itself
1363 // is related (see AliTrack::AddSignal).
1364 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1365 // object, the current signal is automatically related to this AliTrack
1366 // (or derived) object.
1367 // Also a global link to this AliTrack (or derived) object will be stored
1368 // via the AddTrack() facility.
1372 // In case one just wants to relate the current AliSignal to a certain AliTrack
1373 // without a specific signal slot association, it is much more efficient
1374 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1376 // Please also have a look at the docs of the memberfunction ResetLink()
1377 // to prevent the situation of stored pointers to non-existent object.
1379 Int_t j=GetSlotIndex(name);
1380 if (j>0) SetLink(obj,j,k);
1382 ///////////////////////////////////////////////////////////////////////////
1383 void AliSignal::AddLink(TObject* obj,Int_t j)
1385 // Introduce a link (=pointer) to an object for the j-th slot at the first
1387 // Only the pointer values are stored for (backward) reference, meaning
1388 // that the objects of which the pointers are stored are NOT owned
1389 // by the AliSignal object.
1392 // The first slot is at j=1 and the first position is at k=1.
1393 // j=1 is the default value.
1395 // If needed, the storage area for the links is increased automatically.
1397 // In case the pointer argument is zero, no link will be added.
1399 // In principle any object derived from TObject can be referred to by this
1401 // However, this "linking back" facility was introduced to enable AliSignal slots
1402 // to refer directly to the various AliTracks to which the AliSignal object itself
1403 // is related (see AliTrack::AddSignal).
1404 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1405 // object, the current signal is automatically related to this AliTrack
1406 // (or derived) object.
1407 // Also a global link to this AliTrack (or derived) object will be stored
1408 // via the AddTrack() facility.
1412 // In case one just wants to relate the current AliSignal to a certain AliTrack
1413 // without a specific signal slot association, it is much more efficient
1414 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1416 // Please also have a look at the docs of the memberfunction ResetLink()
1417 // to prevent the situation of stored pointers to non-existent object.
1419 if (!obj || j<=0) return;
1421 if (!fLinks) fLinks=new AliObjMatrix();
1424 Int_t n=GetNlinks(dum,j);
1426 for (Int_t k=1; k<=n; k++)
1435 ///////////////////////////////////////////////////////////////////////////
1436 void AliSignal::AddLink(TObject* obj,TString name)
1438 // Introduce a link (=pointer) to an object for the name-spec slot at the first
1440 // Only the pointer values are stored for (backward) reference, meaning
1441 // that the objects of which the pointers are stored are NOT owned
1442 // by the AliSignal object.
1444 // This procedure involves a slot-index search based on the specified name
1445 // at each invokation. This may become slow in case many slots have been
1446 // defined and/or when this procedure is invoked many times.
1447 // In such cases it is preferable to use indexed addressing in the user code
1448 // either directly or via a few invokations of GetSlotIndex().
1450 // In case the pointer argument is zero, indeed a value of zero will be
1451 // stored at the first free position of the specified slotname.
1453 // In principle any object derived from TObject can be referred to by this
1455 // However, this "linking back" facility was introduced to enable AliSignal slots
1456 // to refer directly to the various AliTracks to which the AliSignal object itself
1457 // is related (see AliTrack::AddSignal).
1458 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1459 // object, the current signal is automatically related to this AliTrack
1460 // (or derived) object.
1461 // Also a global link to this AliTrack (or derived) object will be stored
1462 // via the AddTrack() facility.
1466 // In case one just wants to relate the current AliSignal to a certain AliTrack
1467 // without a specific signal slot association, it is much more efficient
1468 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1470 // Please also have a look at the docs of the memberfunction ResetLink()
1471 // to prevent the situation of stored pointers to non-existent object.
1473 Int_t j=GetSlotIndex(name);
1474 if (j>0) AddLink(obj,j);
1476 ///////////////////////////////////////////////////////////////////////////
1477 void AliSignal::ResetLink(Int_t j,Int_t k)
1479 // Reset the link of the j-th slot at position k.
1482 // The first slot is at j=1 and the first position is at k=1.
1483 // j=1 and k=1 are the default values.
1485 // This memberfunction is intended to reset only 1 specified link location.
1486 // For extended functionality, please refer to the memberfuction ResetLinks().
1488 // In general the user should take care of properly clearing the corresponding
1489 // pointer here when the referred object is deleted.
1490 // However, this "linking back" facility was introduced to enable AliSignal slots
1491 // to refer directly to the various AliTracks to which the AliSignal object itself
1492 // is related (see AliTrack::AddSignal).
1493 // As such, the AliTrack destructor already takes care of clearing the corresponding
1494 // links from the various AliSignal slots for all the AliSignal objects that were
1495 // related to that AliTrack.
1496 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1497 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1498 // the AliSignal object when the corresponding AliTrack object is deleted.
1500 // Note : In the internal storage matrix slots=columns positions=rows
1501 if (fLinks) fLinks->RemoveObject(k,j);
1503 ///////////////////////////////////////////////////////////////////////////
1504 void AliSignal::ResetLink(TString name,Int_t k)
1506 // Reset the link of the name-specified slot at position k.
1508 // This memberfunction is intended to reset only 1 specified link location.
1509 // For extended functionality, please refer to the memberfuction ResetLinks().
1511 // This procedure involves a slot-index search based on the specified name
1512 // at each invokation. This may become slow in case many slots have been
1513 // defined and/or when this procedure is invoked many times.
1514 // In such cases it is preferable to use indexed addressing in the user code
1515 // either directly or via a few invokations of GetSlotIndex().
1517 Int_t j=GetSlotIndex(name);
1518 if (j>0) ResetLink(j,k);
1520 ///////////////////////////////////////////////////////////////////////////
1521 void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k)
1523 // Reset single or multiple slot link(s) according to user specified selections.
1527 // This facility only acts on the slot related links.
1528 // The global track reference list will not be affected.
1529 // To remove all references to AliTrack (or derived) objects, please
1530 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1532 // A link is only reset if the stored reference matches the argument "obj".
1533 // In case obj=0 no check on the matching of the stored reference is performed
1534 // and the stored link is always reset in accordance with the other
1535 // selection criteria.
1537 // In case the slot argument "j" is specified, only the links from that
1538 // specified slot will be deleted.
1539 // In case j=0 (default) no checking on the slot index is performed.
1541 // In case the position argument "k" is specified, only the links from that
1542 // specified position will be deleted.
1543 // In case k=0 (default) no checking on the position index is performed.
1545 // So, invokation of ResetLinks(obj) will remove all references to the
1546 // object "obj" from the total AliSignal, whereas ResetLinks(obj,j)
1547 // will remove all references to the object "obj" only from slot "j".
1551 // The first slot is indicated as j=1, whereas the first position is at k=1.
1553 // Invokation of ResetLinks(0,row,col) is equivalent to invoking the
1554 // memberfunction ResetLink(row,col).
1555 // Invoking the latter directly is slightly faster.
1557 // Invokation of ResetLinks(0) will reset all stored references in this AliSignal.
1559 // In general the user should take care of properly clearing the corresponding
1560 // pointer here when the referred object is deleted.
1561 // However, this "linking back" facility was introduced to enable AliSignal slots
1562 // to refer directly to the various AliTracks to which the AliSignal object itself
1563 // is related (see AliTrack::AddSignal).
1564 // As such, the AliTrack destructor already takes care of clearing the corresponding
1565 // links from the various AliSignal slots for all the AliSignal objects that were
1566 // related to that AliTrack.
1567 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1568 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1569 // the AliSignal object when the corresponding AliTrack object is deleted.
1571 if (!fLinks) return;
1573 if (!obj && !j && !k)
1579 // Note : In the internal storage matrix slots=columns positions=rows
1580 fLinks->RemoveObjects(obj,k,j);
1583 ///////////////////////////////////////////////////////////////////////////
1584 void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k)
1586 // Reset single or multiple slot link(s) according to user specified selections.
1590 // This facility only acts on the slot related links.
1591 // The global track reference list will not be affected.
1592 // To remove all references to AliTrack (or derived) objects, please
1593 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1595 // A link is only reset if the stored reference matches the argument "obj".
1596 // In case obj=0 no check on the matching of the stored reference is performed
1597 // and the stored link is always reset in accordance with the other
1598 // selection criteria.
1600 // In case the position argument "k" is specified, only the links from that
1601 // specified position will be deleted.
1602 // In case k=0 (default) no checking on the position index is performed.
1604 // This procedure involves a slot-index search based on the specified name
1605 // at each invokation. This may become slow in case many slots have been
1606 // defined and/or when this procedure is invoked many times.
1607 // In such cases it is preferable to use indexed addressing in the user code
1608 // either directly or via a few invokations of GetSlotIndex().
1610 // In general the user should take care of properly clearing the corresponding
1611 // pointer here when the referred object is deleted.
1612 // However, this "linking back" facility was introduced to enable AliSignal slots
1613 // to refer directly to the various AliTracks to which the AliSignal object itself
1614 // is related (see AliTrack::AddSignal).
1615 // As such, the AliTrack destructor already takes care of clearing the corresponding
1616 // links from the various AliSignal slots for all the AliSignal objects that were
1617 // related to that AliTrack.
1618 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1619 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1620 // the AliSignal object when the corresponding AliTrack object is deleted.
1622 Int_t j=GetSlotIndex(name);
1623 if (j>0) ResetLinks(obj,j,k);
1625 ///////////////////////////////////////////////////////////////////////////
1626 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const
1628 // Provide the slot and position indices of all the storage locations
1629 // of the specified object.
1630 // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays
1631 // from which the (j,k) pairs can be obtained from the corresponding
1632 // array indices like (j,k)=(js.At(i),ks.At(i)).
1633 // The integer return argument represents the number of (j,k) pairs which
1634 // were encountered for the specified object.
1636 // If obj=0 no object selection is performed and all (j,k) indices
1637 // of the stored references for all objects are returned.
1641 // As usual the convention is that slot and position numbering starts at 1.
1643 // This memberfunction always resets the two TArrayI arrays at the start.
1645 // This memberfunction can only be used to obtain the (j,k) indices
1646 // of the object as stored via the SetLink() or AddLink() memberfunction.
1647 // This means that in case the user has entered a TObjArray as object
1648 // (to increase the dimension of the resulting structure), the (j,k)
1649 // indices of that TObjArray are obtained and NOT the indices of the
1650 // actual objects contained in that TObjArray structure.
1655 // Note : In the internal storage matrix slots=columns positions=rows
1656 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js);
1659 ///////////////////////////////////////////////////////////////////////////
1660 Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const
1662 // Provide the position indices of all the storage locations of the
1663 // specified object in the j-th slot of this AliSignal.
1664 // The position indices are returned in the TArrayI array.
1665 // The integer return argument represents the number of storage locations which
1666 // were encountered for the specified object in the j-th slot.
1668 // If obj=0 no object selection is performed and all position indices
1669 // of the stored references for all objects of the j-th slot are returned.
1671 // If j=0 all slots will be scanned and all position indices matching the
1672 // object selection are returned.
1673 // Note that in this case multiple appearances of the same position index
1674 // will only be recorded once in the returned TArrayI array.
1678 // As usual the convention is that slot and position numbering starts at 1.
1680 // This memberfunction always resets the TArrayI array at the start.
1682 // This memberfunction can only be used to obtain the position indices
1683 // of the object as stored via the SetLink() or AddLink() memberfunction.
1684 // This means that in case the user has entered a TObjArray as object
1685 // (to increase the dimension of the resulting structure), the position
1686 // indices of that TObjArray are obtained and NOT the indices of the
1687 // actual objects contained in that TObjArray structure.
1691 // Note : In the internal storage matrix slots=columns positions=rows
1692 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j);
1695 ///////////////////////////////////////////////////////////////////////////
1696 Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const
1698 // Provide the position indices of all the storage locations of the
1699 // specified object in the name-specified slot of this AliSignal.
1700 // The position indices are returned in the TArrayI array.
1701 // The integer return argument represents the number of storage locations which
1702 // were encountered for the specified object in the j-th slot.
1704 // If obj=0 no object selection is performed and all position indices
1705 // of the stored references for all objects of the j-th slot are returned.
1707 // This procedure involves a slot-index search based on the specified name
1708 // at each invokation. This may become slow in case many slots have been
1709 // defined and/or when this procedure is invoked many times.
1710 // In such cases it is preferable to use indexed addressing in the user code
1711 // either directly or via a few invokations of GetSlotIndex().
1713 Int_t j=GetSlotIndex(name);
1715 if (j>0) n=GetIndices(obj,j,ks);
1718 ///////////////////////////////////////////////////////////////////////////
1719 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const
1721 // Provide the slot indices of all the storage locations of the
1722 // specified object for the k-th position in this AliSignal.
1723 // The slot indices are returned in the TArrayI array.
1724 // The integer return argument represents the number of storage locations which
1725 // were encountered for the specified object in the k-th position.
1727 // If obj=0 no object selection is performed and all slot indices
1728 // of the stored references for all objects in the k-th position are returned.
1730 // If k=0 all positions will be scanned and all slot indices matching the
1731 // object selection are returned.
1732 // Note that in this case multiple appearances of the same slot index
1733 // will only be recorded once in the returned TArrayI array.
1737 // As usual the convention is that slot and position numbering starts at 1.
1739 // This memberfunction always resets the TArrayI array at the start.
1741 // This memberfunction can only be used to obtain the slot indices
1742 // of the object as stored via the SetLink() or AddLink() memberfunction.
1743 // This means that in case the user has entered a TObjArray as object
1744 // (to increase the dimension of the resulting structure), the slot
1745 // indices of that TObjArray are obtained and NOT the indices of the
1746 // actual objects contained in that TObjArray structure.
1750 // Note : In the internal storage matrix slots=columns positions=rows
1751 if (fLinks) nrefs=fLinks->GetIndices(obj,k,js);
1754 ///////////////////////////////////////////////////////////////////////////
1755 void AliSignal::SetSwapMode(Int_t swap)
1757 // Set swapmode flag for the internal link storage.
1758 // In case for the stored links the maximum slot number differs considerably
1759 // from the maximum position number, it might be more efficient
1760 // (w.r.t. memory usage and/or output file size) to internally store the
1761 // link reference matrix with the rows and colums swapped.
1762 // This swapping is only related with the internal storage and as such
1763 // is completely hidden for the user.
1764 // At invokation of this memberfunction the default argument is swap=1.
1766 // Note : The swap mode can only be set as long as no links are
1767 // stored in the AliSignal (i.e. a new instance of AliSignal
1768 // or after invokation of the Reset() or ResetLinks() function).
1770 if (!fLinks) fLinks=new AliObjMatrix();
1771 fLinks->SetSwapMode(swap);
1773 ///////////////////////////////////////////////////////////////////////////
1774 Int_t AliSignal::GetSwapMode() const
1776 // Provide swapmode flag of the link storage.
1778 if (fLinks) swap=fLinks->GetSwapMode();
1781 ///////////////////////////////////////////////////////////////////////////
1782 void AliSignal::SetDevice(TObject* dev)
1784 // Store the pointer to the device which owns this AliSignal object.
1785 // This memberfunction is meant for internal use in AliDevice.
1788 ///////////////////////////////////////////////////////////////////////////
1789 AliDevice* AliSignal::GetDevice() const
1791 // Provide the pointer to the device which owns this AliSignal object.
1792 return (AliDevice*)fDevice;
1794 ///////////////////////////////////////////////////////////////////////////
1795 void AliSignal::AddTrack(AliTrack& t,Int_t mode)
1797 // Relate an AliTrack object to this signal.
1798 // Only the pointer values are stored for (backward) reference, meaning
1799 // that the tracks of which the pointers are stored are NOT owned
1800 // by the AliSignal object.
1802 // mode = 0 : Only the reference to the specified track is stored in
1803 // the current signal, without storing the (backward) reference
1804 // to this signal into the AliTrack structure.
1805 // 1 : The (backward) reference to the current signal is also automatically
1806 // stored into the AliTrack (or derived) object specified in the
1809 // The default is mode=1.
1811 if (!fTracks) fTracks=new TObjArray(1);
1813 // Check if this track is already stored for this signal
1814 Int_t ntk=GetNtracks();
1815 for (Int_t i=0; i<ntk; i++)
1817 if (&t==fTracks->At(i)) return;
1821 if (mode==1) t.AddSignal(*this,0);
1823 ///////////////////////////////////////////////////////////////////////////
1824 void AliSignal::RemoveTrack(AliTrack& t,Int_t mode)
1826 // Remove related AliTrack object from this signal.
1827 // Also all references (if any) to this track in the slot links area
1830 // mode = 0 : All references to the specified track are removed from
1831 // the current signal, without removing the (backward) reference
1832 // to this signal from the AliTrack structure.
1833 // 1 : The (backward) reference to the current signal is also automatically
1834 // removed from the AliTrack (or derived) object specified in the
1837 // The default is mode=1.
1841 AliTrack* test=(AliTrack*)fTracks->Remove(&t);
1842 if (test) fTracks->Compress();
1847 if (mode==1) t.RemoveSignal(*this,0);
1849 ///////////////////////////////////////////////////////////////////////////
1850 void AliSignal::RemoveTracks(Int_t mode)
1852 // Remove all related AliTrack objects from this signal.
1853 // Also all references (if any) to the related tracks in the slot links area
1856 // mode = 0 : All track references are removed from the current signal,
1857 // without removing the (backward) references to this signal from
1858 // the corresponding AliTrack objects.
1859 // 1 : The (backward) references to the current signal are also automatically
1860 // removed from the corresponding AliTrack (or derived) objects.
1862 // The default is mode=1.
1864 if (!fTracks) return;
1866 Int_t ntk=GetNtracks();
1867 for (Int_t i=0; i<ntk; i++)
1869 AliTrack* tx=(AliTrack*)fTracks->At(i);
1873 if (mode==1) tx->RemoveSignal(*this,0);
1880 ///////////////////////////////////////////////////////////////////////////
1881 Int_t AliSignal::GetNtracks(AliTrack* t) const
1883 // Provide the number of related AliTracks.
1884 // In case an AliTrack pointer is specified as input argument,
1885 // the number returned will be the number of occurrences (i.e. 0 or 1)
1886 // for that specified track.
1887 // By default t=0, which implies that just the number of all associated
1888 // tracks will be returned.
1890 if (!fTracks) return 0;
1892 Int_t ntk=fTracks->GetEntries();
1896 for (Int_t i=0; i<ntk; i++)
1898 AliTrack* tx=(AliTrack*)fTracks->At(i);
1899 if (tx==t) return 1;
1904 ///////////////////////////////////////////////////////////////////////////
1905 AliTrack* AliSignal::GetTrack(Int_t j) const
1907 // Provide the related AliTrack number j.
1908 // Note : j=1 denotes the first track.
1910 if (!fTracks) return 0;
1912 if ((j >= 1) && (j <= GetNtracks()))
1914 return (AliTrack*)fTracks->At(j-1);
1918 cout << " *AliSignal* track number : " << j << " out of range."
1919 << " Ntk = " << GetNtracks() << endl;
1923 ///////////////////////////////////////////////////////////////////////////
1924 AliTrack* AliSignal::GetIdTrack(Int_t id) const
1926 // Return the track with user identifier "id" of this signal
1927 if (!fTracks) return 0;
1930 for (Int_t i=0; i<GetNtracks(); i++)
1932 tx=(AliTrack*)fTracks->At(i);
1933 if (id == tx->GetId()) return tx;
1935 return 0; // No matching id found
1937 ///////////////////////////////////////////////////////////////////////////
1938 TObject* AliSignal::Clone(const char* name) const
1940 // Make a deep copy of the current object and provide the pointer to the copy.
1941 // This memberfunction enables automatic creation of new objects of the
1942 // correct type depending on the object type, a feature which may be very useful
1943 // for containers when adding objects in case the container owns the objects.
1944 // This feature allows e.g. AliTrack to store either AliSignal objects or
1945 // objects derived from AliSignal via the AddSignal memberfunction, provided
1946 // these derived classes also have a proper Clone memberfunction.
1948 AliSignal* sig=new AliSignal(*this);
1951 if (strlen(name)) sig->SetName(name);
1955 ///////////////////////////////////////////////////////////////////////////