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();
190 for (Int_t i=1; i<=n; i++)
192 if (s.GetSignalFlag(i))
195 lock=s.GetLockValue();
203 for (Int_t j=1; j<=n; j++)
205 if (s.GetErrorFlag(j))
207 val=s.GetSignalError(j);
208 lock=s.GetLockValue();
210 SetSignalError(val,j);
216 for (Int_t k=1; k<=n; k++)
218 TH1F* hist=s.GetWaveform(k);
219 if (hist) SetWaveform(hist,k);
225 n=s.GetIndices(dum,slotarr,posarr);
227 for (Int_t idx=0; idx<n; idx++)
229 slot=slotarr.At(idx);
231 TObject* obj=s.GetLink(slot,pos);
232 if (obj) SetLink(obj,slot,pos);
235 Int_t ntk=s.GetNtracks();
238 fTracks=new TObjArray(ntk);
239 for (Int_t it=1; it<=ntk; it++)
241 AliTrack* tx=s.GetTrack(it);
246 ///////////////////////////////////////////////////////////////////////////
247 void AliSignal::Reset(Int_t mode)
249 // Reset all signal and position values and errors to 0.
251 // mode = 0 Reset position and all signal values and their errors to 0.
252 // The waveform histograms are reset, but the calibration
253 // constants (i.e. gains and offsets) are kept.
254 // 1 Reset position and delete the signal and error storage arrays.
255 // Also the waveform histograms, gains and offset arrays are deleted.
257 // The default when invoking Reset() corresponds to mode=0.
259 // Note : In all cases the storage of the various links will be reset.
260 // The UniqueID, name and title will NOT be reset.
261 // In case the user wants to reset these attributes, this has to
262 // be done explicitly via the SET facilities.
264 // The usage of mode=0 allows to re-use the allocated memory for new
265 // signal (and error) values. This behaviour is preferable (i.e. faster)
266 // in case the various signals always contain the same number of values
267 // and have the same calibration constants.
268 // The usage of mode=1 is slower, but allows a more efficient memory
269 // occupation (and smaller output file size) in case the different
270 // signals have a variable number of values.
272 // For more specific actions see ResetPosition(), ResetSignals(),
273 // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(),
274 // DeleteWaveform() and DeleteCalibrations().
277 if (mode<0 || mode>1)
279 cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl;
280 cout << " Default mode=0 will be used." << endl;
292 DeleteCalibrations();
295 if (fLinks) fLinks->Reset();
304 ///////////////////////////////////////////////////////////////////////////
305 void AliSignal::ResetSignals(Int_t mode)
307 // Reset various signal data according to user selection.
309 // mode = 0 Reset all signal values, their errors and all waveform histos.
310 // 1 Reset only signal values and waveform histos.
311 // 2 Reset only signal errors and waveform histos.
312 // -1 Reset only signal values.
313 // -2 Reset only signal errors.
315 // The default when invoking ResetSignals() corresponds to mode=0.
319 cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl;
320 cout << " Default mode=0 will be used." << endl;
327 if (fSignals && (abs(mode)==0 || abs(mode)==1))
329 for (Int_t i=1; i<=fSignals->GetSize(); i++)
331 fSignals->AddAt(0,i-1);
332 eflag=GetErrorFlag(i);
333 SetSigFlags(0,eflag,i);
337 if (fDsignals && (abs(mode)==0 || abs(mode)==2))
339 for (Int_t j=1; j<=fDsignals->GetSize(); j++)
341 fDsignals->AddAt(0,j-1);
342 sflag=GetSignalFlag(j);
343 SetSigFlags(sflag,0,j);
347 if (mode>=0) ResetWaveform(0);
349 ///////////////////////////////////////////////////////////////////////////
350 void AliSignal::DeleteSignals(Int_t mode)
352 // Delete storage arrays of various signal data according to user selection.
354 // mode = 0 Delete arrays of signal values, their errors and all waveform histos.
355 // 1 Delete only signal values array and waveform histos.
356 // 2 Delete only signal errors array and waveform histos.
357 // -1 Delete only signal values array.
358 // -2 Delete only signal errors array.
360 // The default when invoking DeleteSignals() corresponds to mode=0.
364 cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl;
365 cout << " Default mode=0 will be used." << endl;
369 if (fSignals && (abs(mode)==0 || abs(mode)==1))
375 if (fDsignals && (abs(mode)==0 || abs(mode)==2))
389 else if (abs(mode)==1)
391 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
393 eflag=GetErrorFlag(i);
394 SetSigFlags(0,eflag,i);
397 else if (abs(mode)==2)
399 for (Int_t j=1; j<=fSigflags->GetSize(); j++)
401 sflag=GetSignalFlag(j);
402 SetSigFlags(sflag,0,j);
406 if (mode>=0) DeleteWaveform(0);
408 ///////////////////////////////////////////////////////////////////////////
409 void AliSignal::SetSignal(Double_t sig,Int_t j)
411 // Store signal value for the j-th (default j=1) slot.
414 // 1) The first signal slot is at j=1.
415 // 2) In case the 'lock' flag was set for the specified slot, the new
416 // signal value will not be stored.
417 // One has to unlock the specified slot first in case one really wants
418 // to overwite the signal value.
419 // In case the value of the index j exceeds the maximum number of reserved
420 // slots for signal values, the number of reserved slots for the
421 // signal values is increased automatically.
423 if (GetLockValue(j)) return;
427 fSignals=new TArrayF(j);
431 Int_t size=fSignals->GetSize();
438 fSignals->AddAt(float(sig),j-1);
440 Int_t eflag=GetErrorFlag(j);
441 SetSigFlags(1,eflag,j);
443 ///////////////////////////////////////////////////////////////////////////
444 void AliSignal::SetSignal(Double_t sig,TString name)
446 // Store signal value for the name-specified slot.
450 // In case the 'lock' flag was set for the specified slot, the new
451 // signal value will not be stored.
452 // One has to unlock the specified slot first in case one really wants
453 // to overwite the signal value.
455 // This procedure involves a slot-index search based on the specified name
456 // at each invokation. This may become slow in case many slots have been
457 // defined and/or when this procedure is invoked many times.
458 // In such cases it is preferable to use indexed addressing in the user code
459 // either directly or via a few invokations of GetSlotIndex().
461 Int_t j=GetSlotIndex(name);
464 if (!GetLockValue(j)) SetSignal(sig,j);
467 ///////////////////////////////////////////////////////////////////////////
468 void AliSignal::AddSignal(Double_t sig,Int_t j)
470 // Add value to the signal of the j-th (default j=1) slot.
473 // 1) The first signal slot is at j=1.
474 // 2) In case the 'lock' flag was set for the specified slot, the new
475 // signal value will not be stored.
476 // One has to unlock the specified slot first in case one really wants
477 // to overwite the signal value.
478 // In case the value of the index j exceeds the maximum number of reserved
479 // slots for signal values, the number of reserved slots for the
480 // signal values is increased automatically.
482 if (GetLockValue(j)) return;
486 fSignals=new TArrayF(j);
490 Int_t size=fSignals->GetSize();
497 Float_t sum=(fSignals->At(j-1))+sig;
498 fSignals->AddAt(sum,j-1);
500 Int_t eflag=GetErrorFlag(j);
501 SetSigFlags(1,eflag,j);
503 ///////////////////////////////////////////////////////////////////////////
504 void AliSignal::AddSignal(Double_t sig,TString name)
506 // Add value to the signal of the name-specified slot.
510 // In case the 'lock' flag was set for the specified slot, the new
511 // signal value will not be stored.
512 // One has to unlock the specified slot first in case one really wants
513 // to overwite the signal value.
515 // This procedure involves a slot-index search based on the specified name
516 // at each invokation. This may become slow in case many slots have been
517 // defined and/or when this procedure is invoked many times.
518 // In such cases it is preferable to use indexed addressing in the user code
519 // either directly or via a few invokations of GetSlotIndex().
521 Int_t j=GetSlotIndex(name);
524 if (!GetLockValue(j)) AddSignal(sig,j);
527 ///////////////////////////////////////////////////////////////////////////
528 Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const
530 // Provide signal value of the j-th (default j=1) slot.
531 // Note : The first signal slot is at j=1.
532 // In case no signal is present or the input argument "j" or "mode" is invalid,
533 // the value 0 is returned.
534 // The parameter "mode" allows for automatic (de)calibration of the signal
535 // (e.g. gain etc... correction or via explicit (de)calibration functions).
537 // mode = 0 : Just the j-th signal is returned.
538 // 1 : The j-th signal is corrected for the gain, offset, dead flag etc...
539 // In case the j-th slot was marked dead, 0 is returned.
540 // In case the gain value was not set, gain=1 will be assumed.
541 // In case the gain value was 0, a signal value of 0 is returned.
542 // In case the offset value was not set, offset=0 will be assumed.
543 // 2 : Same as mode=1 but gain, offset dead flag etc... are taken from
544 // the AliDevice which owns this AliSignal object.
545 // The corresponding AliDevice slot is obtained via matching of
546 // the slotnames. In case this fails, the slotindex "j" of the
547 // input argument will be used.
548 // In case this AliSignal object has no parent AliDevice, just
549 // the j-th signal is returned (like with mode=0).
550 // 3 : The j-th signal is corrected using the corresponding calibration
552 // In case the j-th slot was marked dead, 0 is returned.
553 // In case no calibration function is present, just the j-th signal
554 // is returned (like with mode=0).
555 // 4 : Same as mode=3 but the calibration function and dead flag are
556 // taken from the AliDevice which owns this AliSignal object.
557 // The corresponding AliDevice slot is obtained via matching of
558 // the slotnames. In case this fails, the slotindex "j" of the
559 // input argument will be used.
560 // 5 : Same as mode=2 but in case no parent AliDevice is present
561 // an automatic switch to mode=1 will be made.
562 // 6 : Same as mode=4 but in case no parent AliDevice is present
563 // an automatic switch to mode=3 will be made.
564 // 7 : Same as mode=3 but in case no calibration function is present
565 // an automatic switch to mode=4 will be made.
566 // 8 : Same as mode=7 but also the corresponding dead flag of the
567 // parent device (if any) will be checked.
568 // If either the dead flag of the requested signal slot of this
569 // AliSignal object or the corresponding parent device slot is
570 // set, 0 is returned.
572 // <0 : The corresponding de-correction or de-calibration is performed
574 // The corrected signal (sigc) is determined as follows :
576 // sigc=(signal/gain)-offset
578 // The de-corrected signal is determined as follows :
580 // signal=(sigc+offset)*gain
582 // The default is mode=0.
584 if (abs(mode)>8) return 0;
591 // Get the corresponding slot index (and dead flag) of the parent device
594 AliSignal* parent=(AliSignal*)GetDevice();
595 if ((abs(mode)==2 || abs(mode)>=4) && parent)
597 TString name=GetSlotName(j);
598 if (strlen(name.Data())) pj=parent->GetSlotIndex(name);
599 if (abs(mode)==8 && pj) pdead=parent->GetDeadValue(pj);
602 if (mode==-8) mode=-7;
604 AliSignal* sx=(AliSignal*)this;
609 f=sx->GetCalFunction(jcal);
621 f=sx->GetDecalFunction(jcal);
632 if (abs(mode)==2 || abs(mode)>=4)
634 sx=(AliSignal*)GetDevice();
637 if (!sx && abs(mode)>=5) sx=(AliSignal*)this;
639 if (mode==-5) mode=-2;
641 if (mode==-6) mode=-3;
645 if (j>0 && j<=(fSignals->GetSize()))
647 sig=fSignals->At(j-1);
649 if (mode==0 || !sx) return sig;
651 // Check for the dead flag setting
652 if (sx->GetDeadValue(jcal) || pdead) return 0;
654 // (De)correct the signal for the gain and offset
655 if (abs(mode)==1 || abs(mode)==2)
657 if (sx->GetGainFlag(jcal)) gain=sx->GetGain(jcal);
658 if (sx->GetOffsetFlag(jcal)) offset=sx->GetOffset(jcal);
662 if (mode>0) sig=(sig/gain)-offset; // Gain and offset correction
663 if (mode<0) sig=(sig+offset)*gain; // Gain and offset de-correction
672 // (De)calibrate the signal with the corresponding (de)calibration function
673 if (abs(mode)==3 || abs(mode)==4)
675 f=sx->GetCalFunction(jcal);
676 if (mode<0) f=sx->GetDecalFunction(jcal);
677 if (f) sig=f->Eval(sig);
683 cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl;
688 ///////////////////////////////////////////////////////////////////////////
689 Float_t AliSignal::GetSignal(TString name,Int_t mode) const
691 // Provide signal value of the name-specified slot.
692 // In case no signal is present, 0 is returned.
693 // The parameter "mode" allows for automatic (de)calibration of the signal
694 // (e.g. gain etc... correction or via explicit (de)calibration functions).
695 // For further details about the (de)calibration modes, please refer to the
696 // corresponding slot-index based memberfunction.
698 // The default is mode=0.
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);
708 if (j>0) val=GetSignal(j,mode);
711 ///////////////////////////////////////////////////////////////////////////
712 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
714 // Store error on the signal for the j-th (default j=1) slot.
717 // 1) The first signal slot is at j=1.
718 // 2) In case the 'lock' flag was set for the specified slot, the new
719 // signal error value will not be stored.
720 // One has to unlock the specified slot first in case one really wants
721 // to overwite the signal error value.
722 // In case the value of the index j exceeds the maximum number of reserved
723 // slots for signal error values, the number of reserved slots for the
724 // signal errors is increased automatically.
726 if (GetLockValue(j)) return;
730 fDsignals=new TArrayF(j);
734 Int_t size=fDsignals->GetSize();
741 fDsignals->AddAt(float(dsig),j-1);
743 Int_t sflag=GetSignalFlag(j);
744 SetSigFlags(sflag,1,j);
746 ///////////////////////////////////////////////////////////////////////////
747 void AliSignal::SetSignalError(Double_t dsig,TString name)
749 // Store error on the signal for the name-specified slot.
753 // In case the 'lock' flag was set for the specified slot, the new
754 // signal error value will not be stored.
755 // One has to unlock the specified slot first in case one really wants
756 // to overwite the signal error value.
758 // This procedure involves a slot-index search based on the specified name
759 // at each invokation. This may become slow in case many slots have been
760 // defined and/or when this procedure is invoked many times.
761 // In such cases it is preferable to use indexed addressing in the user code
762 // either directly or via a few invokations of GetSlotIndex().
764 Int_t j=GetSlotIndex(name);
767 if (!GetLockValue(j)) SetSignalError(dsig,j);
770 ///////////////////////////////////////////////////////////////////////////
771 Float_t AliSignal::GetSignalError(Int_t j) const
773 // Provide error on the signal of the j-th (default j=1) slot.
774 // Note : The first signal slot is at j=1.
775 // In case no signal is present or the argument j is invalid, 0 is returned.
779 if (j>0 && j<=(fDsignals->GetSize()))
781 err=fDsignals->At(j-1);
785 cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl;
790 ///////////////////////////////////////////////////////////////////////////
791 Float_t AliSignal::GetSignalError(TString name) const
793 // Provide error on the signal of the name-specified slot.
795 // This procedure involves a slot-index search based on the specified name
796 // at each invokation. This may become slow in case many slots have been
797 // defined and/or when this procedure is invoked many times.
798 // In such cases it is preferable to use indexed addressing in the user code
799 // either directly or via a few invokations of GetSlotIndex().
801 Int_t j=GetSlotIndex(name);
803 if (j>0) val=GetSignalError(j);
806 ///////////////////////////////////////////////////////////////////////////
807 void AliSignal::Data(TString f,TString u) const
809 // Provide all signal information within the coordinate frame f.
811 // The string argument "u" allows to choose between different angular units
812 // in case e.g. a spherical frame is selected.
813 // u = "rad" : angles provided in radians
814 // "deg" : angles provided in degrees
816 // The defaults are f="car" and u="rad".
818 const char* name=GetName();
819 const char* title=GetTitle();
821 cout << " *" << ClassName() << "::Data* Id : " << GetUniqueID();
822 if (strlen(name)) cout << " Name : " << name;
823 if (strlen(title)) cout << " Title : " << title;
826 AliPosition::Data(f,u);
829 const char* devname=fDevice->GetName();
830 const char* devtitle=fDevice->GetTitle();
831 cout << " Owned by device : " << fDevice->ClassName()
832 << " Id : " << fDevice->GetUniqueID();
833 if (strlen(devname)) cout << " Name : " << devname;
834 if (strlen(devtitle)) cout << " Title : " << devtitle;
838 // Provide an overview of the stored waveforms
841 // Provide an overview of the associated tracks
844 // Provide an overview of all the data and attribute slots
847 ///////////////////////////////////////////////////////////////////////////
848 void AliSignal::List(Int_t j) const
850 // Provide signal information for the j-th slot.
851 // The first slot is at j=1.
852 // In case j=0 (default) the data of all slots will be listed.
853 // In case j=-1 the data of all slots will be listed, but the header
854 // information will be suppressed.
858 cout << " *AliSignal::List* Invalid argument j = " << j << endl;
864 const char* name=GetName();
865 const char* title=GetTitle();
867 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
868 if (strlen(name)) cout << " Name : " << name;
869 if (strlen(title)) cout << " Title : " << title;
873 const char* devname=fDevice->GetName();
874 const char* devtitle=fDevice->GetTitle();
875 cout << " Owned by device : " << fDevice->ClassName();
876 if (strlen(devname)) cout << " Name : " << devname;
877 if (strlen(devtitle)) cout << " Title : " << devtitle;
884 if (GetNlinks()) nlinkslots=fLinks->GetMaxColumn();
885 if (nlinkslots>n) n=nlinkslots;
894 for (Int_t i=1; i<=n; i++)
897 nrefs=GetIndices(obj,i,posarr);
899 if (GetSignalFlag(i) || GetErrorFlag(i) || GetCalFunction(i) || GetDecalFunction(i) || GetCalWord(i) || nrefs)
901 cout << " Slot : " << i;
902 if (GetSignalFlag(i)) cout << " Signal value : " << GetSignal(i);
903 if (GetErrorFlag(i)) cout << " error : " << GetSignalError(i);
907 for (Int_t k=0; k<nrefs; k++)
913 cout << " Link at position " << pos << " to : " << obj->ClassName();
914 if (obj->InheritsFrom("TNamed"))
916 const char* lname=obj->GetName();
917 const char* ltitle=obj->GetTitle();
918 if (strlen(lname)) cout << " Name : " << lname;
919 if (strlen(ltitle)) cout << " Title : " << ltitle;
932 nrefs=GetIndices(obj,j,posarr);
934 if (GetSignalFlag(j) || GetErrorFlag(j) || GetCalFunction(j) || GetDecalFunction(j) || GetCalWord(j) || nrefs)
936 cout << " Slot : " << j;
937 if (GetSignalFlag(j)) cout << " Signal value : " << GetSignal(j);
938 if (GetErrorFlag(j)) cout << " error : " << GetSignalError(j);
942 for (Int_t kj=0; kj<nrefs; kj++)
948 cout << " Link at position " << pos << " to : " << obj->ClassName();
949 if (obj->InheritsFrom("TNamed"))
951 const char* lnamej=obj->GetName();
952 const char* ltitlej=obj->GetTitle();
953 if (strlen(lnamej)) cout << " Name : " << lnamej;
954 if (strlen(ltitlej)) cout << " Title : " << ltitlej;
963 ///////////////////////////////////////////////////////////////////////////
964 void AliSignal::List(TString name) const
966 // Provide signal information for the name-specified slot.
968 // This procedure involves a slot-index search based on the specified name
969 // at each invokation. This may become slow in case many slots have been
970 // defined and/or when this procedure is invoked many times.
971 // In such cases it is preferable to use indexed addressing in the user code
972 // either directly or via a few invokations of GetSlotIndex().
974 Int_t j=GetSlotIndex(name);
977 ///////////////////////////////////////////////////////////////////////////
978 void AliSignal::ListWaveform(Int_t j) const
980 // Provide information for the j-th waveform.
981 // The first waveform is at j=1.
982 // In case j=0 (default) the info of all waveforms will be listed.
983 // In case j=-1 the info of all waveforms will be listed, but the header
984 // information will be suppressed.
988 cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl;
994 const char* name=GetName();
995 const char* title=GetTitle();
997 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
998 if (strlen(name)) cout << " Name : " << name;
999 if (strlen(title)) cout << " Title : " << title;
1003 const char* devname=fDevice->GetName();
1004 const char* devtitle=fDevice->GetTitle();
1005 cout << " Owned by device : " << fDevice->ClassName();
1006 if (strlen(devname)) cout << " Name : " << devname;
1007 if (strlen(devtitle)) cout << " Title : " << devtitle;
1012 Int_t n=GetNwaveforms();
1017 for (Int_t i=1; i<=n; i++)
1022 const char* wfname=obj->GetName();
1023 const char* wftitle=obj->GetTitle();
1024 cout << " Waveform " << i << " : " << obj->ClassName();
1025 if (strlen(wfname)) cout << " Name : " << wfname;
1026 if (strlen(wftitle)) cout << " Title : " << wftitle;
1038 const char* wfnamej=obj->GetName();
1039 const char* wftitlej=obj->GetTitle();
1040 cout << " Waveform " << j << " : " << obj->ClassName();
1041 if (strlen(wfnamej)) cout << " Name : " << wfnamej;
1042 if (strlen(wftitlej)) cout << " Title : " << wftitlej;
1048 ///////////////////////////////////////////////////////////////////////////
1049 void AliSignal::ListTrack(Int_t j) const
1051 // Provide information for the j-th associated track.
1052 // The first associated track is at j=1.
1053 // In case j=0 (default) the info of all associated tracks will be listed.
1054 // In case j=-1 the info of all tracks will be listed, but the header
1055 // information will be suppressed.
1059 cout << " *AliSignal::ListTrack* Invalid argument j = " << j << endl;
1065 const char* name=GetName();
1066 const char* title=GetTitle();
1068 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
1069 if (strlen(name)) cout << " Name : " << name;
1070 if (strlen(title)) cout << " Title : " << title;
1074 const char* devname=fDevice->GetName();
1075 const char* devtitle=fDevice->GetTitle();
1076 cout << " Owned by device : " << fDevice->ClassName();
1077 if (strlen(devname)) cout << " Name : " << devname;
1078 if (strlen(devtitle)) cout << " Title : " << devtitle;
1083 Int_t n=GetNtracks();
1088 for (Int_t i=1; i<=n; i++)
1093 const char* txname=tx->GetName();
1094 const char* txtitle=tx->GetTitle();
1095 cout << " Track " << i << " : " << tx->ClassName() << " Id : " << tx->GetId();
1096 if (strlen(txname)) cout << " Name : " << txname;
1097 if (strlen(txtitle)) cout << " Title : " << txtitle;
1109 const char* txnamej=tx->GetName();
1110 const char* txtitlej=tx->GetTitle();
1111 cout << " Track " << j << " : " << tx->ClassName() << " Id : " << tx->GetId();
1112 if (strlen(txnamej)) cout << " Name : " << txnamej;
1113 if (strlen(txtitlej)) cout << " Title : " << txtitlej;
1119 ///////////////////////////////////////////////////////////////////////////
1120 Int_t AliSignal::GetNvalues() const
1122 // Provide the number of values for this signal.
1124 if (!fSignals) return 0;
1127 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
1129 if (GetSignalFlag(i)) n=i;
1134 ///////////////////////////////////////////////////////////////////////////
1135 Int_t AliSignal::GetNerrors() const
1137 // Provide the number specified errors on the values for this signal.
1139 if (!fDsignals) return 0;
1142 for (Int_t i=1; i<=fSigflags->GetSize(); i++)
1144 if (GetErrorFlag(i)) n=i;
1149 ///////////////////////////////////////////////////////////////////////////
1150 void AliSignal::SetSigFlags(Int_t is,Int_t ie,Int_t j)
1152 // Store signal and/or error value flags of the j-th (default j=1) slot.
1153 // Note : The first slot is at j=1.
1154 // In case the value of the index j exceeds the maximum number of reserved
1155 // slots for the flags, the number of reserved slots for the flags is
1156 // increased automatically.
1157 // The value stored is : 10*signalflag + errorflag.
1161 cout << " *AliSignal::SetSigFlags* Invalid argument j = " << j << endl;
1167 fSigflags=new TArrayI(j);
1170 Int_t size=fSigflags->GetSize();
1177 Int_t word=10*is+ie;
1179 fSigflags->AddAt(word,j-1);
1181 ///////////////////////////////////////////////////////////////////////////
1182 Int_t AliSignal::GetSignalFlag(Int_t j) const
1184 // Provide signal value flag of the j-th (default j=1) slot.
1186 // flag = 1 : Signal value was set
1187 // 0 : Signal value was not set
1189 // Note : The first attribute slot is at j=1.
1190 // In case j is invalid, 0 is returned.
1194 cout << " *AliSignal::GetSignalFlag* Invalid argument j = " << j << endl;
1200 if (j>0 && j<=(fSigflags->GetSize()))
1202 Int_t word=fSigflags->At(j-1);
1208 ///////////////////////////////////////////////////////////////////////////
1209 Int_t AliSignal::GetSignalFlag(TString name) const
1211 // Provide signal value flag of the name-specified slot.
1213 // flag = 1 : Signal value was set
1214 // 0 : Signal value was not set
1217 // This procedure involves a slot-index search based on the specified name
1218 // at each invokation. This may become slow in case many slots have been
1219 // defined and/or when this procedure is invoked many times.
1220 // In such cases it is preferable to use indexed addressing in the user code
1221 // either directly or via a few invokations of GetSlotIndex().
1223 Int_t j=GetSlotIndex(name);
1225 if (j>0) flag=GetSignalFlag(j);
1228 ///////////////////////////////////////////////////////////////////////////
1229 Int_t AliSignal::GetErrorFlag(Int_t j) const
1231 // Provide error value flag of the j-th (default j=1) slot.
1233 // flag = 1 : Error value was set
1234 // 0 : Error value was not set
1236 // Note : The first attribute slot is at j=1.
1237 // In case j is invalid, 0 is returned.
1241 cout << " *AliSignal::GetErrorFlag* Invalid argument j = " << j << endl;
1247 if (j>0 && j<=(fSigflags->GetSize()))
1249 Int_t word=fSigflags->At(j-1);
1255 ///////////////////////////////////////////////////////////////////////////
1256 Int_t AliSignal::GetErrorFlag(TString name) const
1258 // Provide error value flag of the name-specified slot.
1260 // flag = 1 : Error value was set
1261 // 0 : Error value was not set
1264 // This procedure involves a slot-index search based on the specified name
1265 // at each invokation. This may become slow in case many slots have been
1266 // defined and/or when this procedure is invoked many times.
1267 // In such cases it is preferable to use indexed addressing in the user code
1268 // either directly or via a few invokations of GetSlotIndex().
1270 Int_t j=GetSlotIndex(name);
1272 if (j>0) flag=GetErrorFlag(j);
1275 ///////////////////////////////////////////////////////////////////////////
1276 Int_t AliSignal::GetNslots() const
1278 // Provide the number of existing slots.
1280 Int_t n=AliAttrib::GetNslots();
1282 if (!fSigflags) return n;
1285 for (Int_t i=0; i<fSigflags->GetSize(); i++)
1287 if (fSigflags->At(i)) nflags=i+1;
1290 if (n<nflags) n=nflags;
1294 ///////////////////////////////////////////////////////////////////////////
1295 Int_t AliSignal::GetNwaveforms() const
1297 // Provide the number of specified waveforms for this signal.
1298 // Actually the return value is the highest index of the stored waveforms.
1299 // This allows an index dependent meaning of waveform info (e.g. waveforms
1300 // with various gain values).
1301 // So, when all waveforms are stored in consequetive positions (e.g. 1,2,3),
1302 // this memberfunction returns 3, being both the highest filled position
1303 // and the actual number of waveforms.
1304 // In case only waveforms are stored at positions 1,2,5,7 this memberfunction
1305 // returns a value 7 whereas only 4 actual waveforms are present.
1306 // This implies that when looping over the various waveform slots, one
1307 // always has to check whether the returned pointer value is non-zero
1308 // (which is a good practice anyhow).
1310 if (fWaveforms) n=fWaveforms->GetLast();
1313 ///////////////////////////////////////////////////////////////////////////
1314 TH1F* AliSignal::GetWaveform(Int_t j) const
1316 // Provide pointer to the j-th waveform histogram.
1318 if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1);
1321 ///////////////////////////////////////////////////////////////////////////
1322 TH1F* AliSignal::GetWaveform(TString name) const
1324 // Provide pointer to the waveform histogram with the specified name.
1325 // In case no match is found, zero is returned.
1326 Int_t n=GetNwaveforms();
1328 for (Int_t i=1; i<=n; i++)
1330 TH1F* waveform=GetWaveform(i);
1333 str=waveform->GetName();
1334 if (str == name) return waveform;
1337 return 0; // No match found
1339 ///////////////////////////////////////////////////////////////////////////
1340 Int_t AliSignal::GetWaveformIndex(TString name) const
1342 // Provide index to the waveform histogram with the specified name.
1343 // In case no match is found, zero is returned.
1344 Int_t n=GetNwaveforms();
1346 for (Int_t i=1; i<=n; i++)
1348 TH1F* waveform=GetWaveform(i);
1351 str=waveform->GetName();
1352 if (str == name) return i;
1355 return 0; // No match found
1357 ///////////////////////////////////////////////////////////////////////////
1358 void AliSignal::SetWaveform(TH1F* waveform,Int_t j)
1360 // Set the 1D waveform histogram for the j-th waveform.
1363 // The first waveform position at j=1.
1364 // j=1 is the default value.
1366 // In case the value of the index j exceeds the maximum number of reserved
1367 // positions for the waveforms, the number of reserved positions for the waveforms
1368 // is increased automatically.
1370 // In case the histo pointer argument has the same value as the current waveform
1371 // histogram pointer value, no action is taken since the user has already
1372 // modified the actual histogram.
1374 // In case the histo pointer argument is zero, the current waveform histogram
1375 // is deleted and the pointer set to zero.
1377 // In all other cases the current waveform histogram is deleted and a new
1378 // copy of the input histogram is created which becomes the current waveform
1385 fWaveforms=new TObjArray(j);
1386 fWaveforms->SetOwner();
1389 if (j > fWaveforms->GetSize()) fWaveforms->Expand(j);
1391 TH1F* hcur=(TH1F*)fWaveforms->At(j-1);
1392 if (waveform != hcur)
1396 fWaveforms->Remove(hcur);
1402 hcur=new TH1F(*waveform);
1403 fWaveforms->AddAt(hcur,j-1);
1407 ///////////////////////////////////////////////////////////////////////////
1408 void AliSignal::ResetWaveform(Int_t j)
1410 // Reset the histogram of the j-th (default j=1) waveform.
1411 // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s).
1412 // To actually delete the histograms from memory, use DeleteWaveform().
1413 // Notes : The first position is at j=1.
1414 // j=0 ==> All waveforms will be reset.
1416 if (!fWaveforms) return;
1418 Int_t size=fWaveforms->GetSize();
1420 if ((j>=0) && (j<=size))
1424 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1425 if (hwave) hwave->Reset();
1429 for (Int_t i=0; i<size; i++)
1431 TH1F* hwave=(TH1F*)fWaveforms->At(i);
1432 if (hwave) hwave->Reset();
1438 cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl;
1442 ///////////////////////////////////////////////////////////////////////////
1443 void AliSignal::ResetWaveform(TString name)
1445 // Reset the waveform with the specified name.
1446 Int_t j=GetWaveformIndex(name);
1447 if (j>0) ResetWaveform(j);
1449 ///////////////////////////////////////////////////////////////////////////
1450 void AliSignal::DeleteWaveform(Int_t j)
1452 // Delete the histogram of the j-th (default j=1) waveform.
1453 // Notes : The first position is at j=1.
1454 // j=0 ==> All waveforms will be deleted.
1456 if (!fWaveforms) return;
1458 Int_t size=fWaveforms->GetSize();
1460 if ((j>=0) && (j<=size))
1464 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
1467 fWaveforms->Remove(hwave);
1479 cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl;
1483 ///////////////////////////////////////////////////////////////////////////
1484 void AliSignal::DeleteWaveform(TString name)
1486 // Delete the waveform with the specified name.
1487 Int_t j=GetWaveformIndex(name);
1488 if (j>0) DeleteWaveform(j);
1490 ///////////////////////////////////////////////////////////////////////////
1491 Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const
1493 // Provide the number of links to the specified object for the j-th slot.
1494 // If j=0 (default) all slots will be scanned for the specified object.
1495 // If obj=0 (default) all encountered objects for the specified slot will be counted.
1496 // So, invokation of the default GetNlinks() will return the total number of
1497 // all references to all sorts of stored objects.
1500 cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl;
1504 if (!fLinks) return 0;
1509 n=fLinks->GetNrefs(obj);
1514 n=GetIndices(obj,j,posarr);
1518 ///////////////////////////////////////////////////////////////////////////
1519 Int_t AliSignal::GetNlinks(TObject* obj,TString name) const
1521 // Provide the number of links to the specified object for the name-spec. slot.
1522 // If obj=0 all encountered objects for the specified slot will be counted.
1524 // This procedure involves a slot-index search based on the specified name
1525 // at each invokation. This may become slow in case many slots have been
1526 // defined and/or when this procedure is invoked many times.
1527 // In such cases it is preferable to use indexed addressing in the user code
1528 // either directly or via a few invokations of GetSlotIndex().
1530 Int_t j=GetSlotIndex(name);
1532 if (j>0) n=GetNlinks(obj,j);
1535 ///////////////////////////////////////////////////////////////////////////
1536 TObject* AliSignal::GetLink(Int_t j,Int_t k) const
1538 // Provide pointer of the object linked to the j-th slot at position k.
1541 // Note : In the internal storage matrix slots=columns positions=rows
1542 if (fLinks) obj=fLinks->GetObject(k,j);
1545 ///////////////////////////////////////////////////////////////////////////
1546 TObject* AliSignal::GetLink(TString name,Int_t k) const
1548 // Provide pointer of the object linked to the name-spec. slot at position k.
1550 // This procedure involves a slot-index search based on the specified name
1551 // at each invokation. This may become slow in case many slots have been
1552 // defined and/or when this procedure is invoked many times.
1553 // In such cases it is preferable to use indexed addressing in the user code
1554 // either directly or via a few invokations of GetSlotIndex().
1556 Int_t j=GetSlotIndex(name);
1558 if (j>0) obj=GetLink(j,k);
1561 ///////////////////////////////////////////////////////////////////////////
1562 void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k)
1564 // Introduce a link (=pointer) to an object for the j-th slot at position k.
1565 // Only the pointer values are stored for (backward) reference, meaning
1566 // that the objects of which the pointers are stored are NOT owned
1567 // by the AliSignal object.
1570 // The first slot is at j=1 and the first position is at k=1.
1571 // j=1 and k=1 are the default values.
1573 // If needed, the storage area for the links is increased automatically.
1575 // In case the pointer argument is zero, indeed a value of zero will be
1576 // stored at the specified position (k) for the specified slot (j).
1578 // In principle any object derived from TObject can be referred to by this
1580 // However, this "linking back" facility was introduced to enable AliSignal slots
1581 // to refer directly to the various AliTracks to which the AliSignal object itself
1582 // is related (see AliTrack::AddSignal).
1583 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1584 // object, the current signal is automatically related to this AliTrack
1585 // (or derived) object.
1586 // Also a global link to this AliTrack (or derived) object will be stored
1587 // via the AddTrack() facility.
1591 // In case one just wants to relate the current AliSignal to a certain AliTrack
1592 // without a specific signal slot association, it is much more efficient
1593 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1595 // Please also have a look at the docs of the memberfunction ResetLink()
1596 // to prevent the situation of stored pointers to non-existent object.
1598 if (!fLinks && obj) fLinks=new AliObjMatrix();
1600 if (!fLinks) return;
1602 // Note : In the internal storage matrix slots=columns positions=rows
1603 fLinks->EnterObject(k,j,obj);
1606 if (obj->InheritsFrom("AliTrack"))
1608 AliTrack* t=(AliTrack*)obj;
1613 ///////////////////////////////////////////////////////////////////////////
1614 void AliSignal::SetLink(TObject* obj,TString name,Int_t k)
1616 // Introduce a link (=pointer) to an object for the name-spec. slot at position k.
1617 // Only the pointer values are stored for (backward) reference, meaning
1618 // that the objects of which the pointers are stored are NOT owned
1619 // by the AliSignal object.
1621 // This procedure involves a slot-index search based on the specified name
1622 // at each invokation. This may become slow in case many slots have been
1623 // defined and/or when this procedure is invoked many times.
1624 // In such cases it is preferable to use indexed addressing in the user code
1625 // either directly or via a few invokations of GetSlotIndex().
1627 // In case the pointer argument is zero, indeed a value of zero will be
1628 // stored at the specified position (k) for the specified slotname.
1630 // In principle any object derived from TObject can be referred to by this
1632 // However, this "linking back" facility was introduced to enable AliSignal slots
1633 // to refer directly to the various AliTracks to which the AliSignal object itself
1634 // is related (see AliTrack::AddSignal).
1635 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1636 // object, the current signal is automatically related to this AliTrack
1637 // (or derived) object.
1638 // Also a global link to this AliTrack (or derived) object will be stored
1639 // via the AddTrack() facility.
1643 // In case one just wants to relate the current AliSignal to a certain AliTrack
1644 // without a specific signal slot association, it is much more efficient
1645 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1647 // Please also have a look at the docs of the memberfunction ResetLink()
1648 // to prevent the situation of stored pointers to non-existent object.
1650 Int_t j=GetSlotIndex(name);
1651 if (j>0) SetLink(obj,j,k);
1653 ///////////////////////////////////////////////////////////////////////////
1654 void AliSignal::AddLink(TObject* obj,Int_t j)
1656 // Introduce a link (=pointer) to an object for the j-th slot at the first
1658 // Only the pointer values are stored for (backward) reference, meaning
1659 // that the objects of which the pointers are stored are NOT owned
1660 // by the AliSignal object.
1663 // The first slot is at j=1 and the first position is at k=1.
1664 // j=1 is the default value.
1666 // If needed, the storage area for the links is increased automatically.
1668 // In case the pointer argument is zero, no link will be added.
1670 // In principle any object derived from TObject can be referred to by this
1672 // However, this "linking back" facility was introduced to enable AliSignal slots
1673 // to refer directly to the various AliTracks to which the AliSignal object itself
1674 // is related (see AliTrack::AddSignal).
1675 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1676 // object, the current signal is automatically related to this AliTrack
1677 // (or derived) object.
1678 // Also a global link to this AliTrack (or derived) object will be stored
1679 // via the AddTrack() facility.
1683 // In case one just wants to relate the current AliSignal to a certain AliTrack
1684 // without a specific signal slot association, it is much more efficient
1685 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1687 // Please also have a look at the docs of the memberfunction ResetLink()
1688 // to prevent the situation of stored pointers to non-existent object.
1690 if (!obj || j<=0) return;
1692 if (!fLinks) fLinks=new AliObjMatrix();
1695 Int_t n=GetNlinks(dum,j);
1697 for (Int_t k=1; k<=n; k++)
1706 ///////////////////////////////////////////////////////////////////////////
1707 void AliSignal::AddLink(TObject* obj,TString name)
1709 // Introduce a link (=pointer) to an object for the name-spec slot at the first
1711 // Only the pointer values are stored for (backward) reference, meaning
1712 // that the objects of which the pointers are stored are NOT owned
1713 // by the AliSignal object.
1715 // This procedure involves a slot-index search based on the specified name
1716 // at each invokation. This may become slow in case many slots have been
1717 // defined and/or when this procedure is invoked many times.
1718 // In such cases it is preferable to use indexed addressing in the user code
1719 // either directly or via a few invokations of GetSlotIndex().
1721 // In case the pointer argument is zero, indeed a value of zero will be
1722 // stored at the first free position of the specified slotname.
1724 // In principle any object derived from TObject can be referred to by this
1726 // However, this "linking back" facility was introduced to enable AliSignal slots
1727 // to refer directly to the various AliTracks to which the AliSignal object itself
1728 // is related (see AliTrack::AddSignal).
1729 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1730 // object, the current signal is automatically related to this AliTrack
1731 // (or derived) object.
1732 // Also a global link to this AliTrack (or derived) object will be stored
1733 // via the AddTrack() facility.
1737 // In case one just wants to relate the current AliSignal to a certain AliTrack
1738 // without a specific signal slot association, it is much more efficient
1739 // (both memory and CPU wise) to use the memberfunction AddTrack() instead.
1741 // Please also have a look at the docs of the memberfunction ResetLink()
1742 // to prevent the situation of stored pointers to non-existent object.
1744 Int_t j=GetSlotIndex(name);
1745 if (j>0) AddLink(obj,j);
1747 ///////////////////////////////////////////////////////////////////////////
1748 void AliSignal::ResetLink(Int_t j,Int_t k)
1750 // Reset the link of the j-th slot at position k.
1753 // The first slot is at j=1 and the first position is at k=1.
1754 // j=1 and k=1 are the default values.
1756 // This memberfunction is intended to reset only 1 specified link location.
1757 // For extended functionality, please refer to the memberfuction ResetLinks().
1759 // In general the user should take care of properly clearing the corresponding
1760 // pointer here when the referred object is deleted.
1761 // However, this "linking back" facility was introduced to enable AliSignal slots
1762 // to refer directly to the various AliTracks to which the AliSignal object itself
1763 // is related (see AliTrack::AddSignal).
1764 // As such, the AliTrack destructor already takes care of clearing the corresponding
1765 // links from the various AliSignal slots for all the AliSignal objects that were
1766 // related to that AliTrack.
1767 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1768 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1769 // the AliSignal object when the corresponding AliTrack object is deleted.
1771 // Note : In the internal storage matrix slots=columns positions=rows
1772 if (fLinks) fLinks->RemoveObject(k,j);
1774 ///////////////////////////////////////////////////////////////////////////
1775 void AliSignal::ResetLink(TString name,Int_t k)
1777 // Reset the link of the name-specified slot at position k.
1779 // This memberfunction is intended to reset only 1 specified link location.
1780 // For extended functionality, please refer to the memberfuction ResetLinks().
1782 // This procedure involves a slot-index search based on the specified name
1783 // at each invokation. This may become slow in case many slots have been
1784 // defined and/or when this procedure is invoked many times.
1785 // In such cases it is preferable to use indexed addressing in the user code
1786 // either directly or via a few invokations of GetSlotIndex().
1788 Int_t j=GetSlotIndex(name);
1789 if (j>0) ResetLink(j,k);
1791 ///////////////////////////////////////////////////////////////////////////
1792 void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k)
1794 // Reset single or multiple slot link(s) according to user specified selections.
1798 // This facility only acts on the slot related links.
1799 // The global track reference list will not be affected.
1800 // To remove all references to AliTrack (or derived) objects, please
1801 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1803 // A link is only reset if the stored reference matches the argument "obj".
1804 // In case obj=0 no check on the matching of the stored reference is performed
1805 // and the stored link is always reset in accordance with the other
1806 // selection criteria.
1808 // In case the slot argument "j" is specified, only the links from that
1809 // specified slot will be deleted.
1810 // In case j=0 (default) no checking on the slot index is performed.
1812 // In case the position argument "k" is specified, only the links from that
1813 // specified position will be deleted.
1814 // In case k=0 (default) no checking on the position index is performed.
1816 // So, invokation of ResetLinks(obj) will remove all references to the
1817 // object "obj" from the total AliSignal, whereas ResetLinks(obj,j)
1818 // will remove all references to the object "obj" only from slot "j".
1822 // The first slot is indicated as j=1, whereas the first position is at k=1.
1824 // Invokation of ResetLinks(0,row,col) is equivalent to invoking the
1825 // memberfunction ResetLink(row,col).
1826 // Invoking the latter directly is slightly faster.
1828 // Invokation of ResetLinks(0) will reset all stored references in this AliSignal.
1830 // In general the user should take care of properly clearing the corresponding
1831 // pointer here when the referred object is deleted.
1832 // However, this "linking back" facility was introduced to enable AliSignal slots
1833 // to refer directly to the various AliTracks to which the AliSignal object itself
1834 // is related (see AliTrack::AddSignal).
1835 // As such, the AliTrack destructor already takes care of clearing the corresponding
1836 // links from the various AliSignal slots for all the AliSignal objects that were
1837 // related to that AliTrack.
1838 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1839 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1840 // the AliSignal object when the corresponding AliTrack object is deleted.
1842 if (!fLinks) return;
1844 if (!obj && !j && !k)
1850 // Note : In the internal storage matrix slots=columns positions=rows
1851 fLinks->RemoveObjects(obj,k,j);
1854 ///////////////////////////////////////////////////////////////////////////
1855 void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k)
1857 // Reset single or multiple slot link(s) according to user specified selections.
1861 // This facility only acts on the slot related links.
1862 // The global track reference list will not be affected.
1863 // To remove all references to AliTrack (or derived) objects, please
1864 // use the RemoveTrack() of RemoveTracks() memberfunctions.
1866 // A link is only reset if the stored reference matches the argument "obj".
1867 // In case obj=0 no check on the matching of the stored reference is performed
1868 // and the stored link is always reset in accordance with the other
1869 // selection criteria.
1871 // In case the position argument "k" is specified, only the links from that
1872 // specified position will be deleted.
1873 // In case k=0 (default) no checking on the position index is performed.
1875 // This procedure involves a slot-index search based on the specified name
1876 // at each invokation. This may become slow in case many slots have been
1877 // defined and/or when this procedure is invoked many times.
1878 // In such cases it is preferable to use indexed addressing in the user code
1879 // either directly or via a few invokations of GetSlotIndex().
1881 // In general the user should take care of properly clearing the corresponding
1882 // pointer here when the referred object is deleted.
1883 // However, this "linking back" facility was introduced to enable AliSignal slots
1884 // to refer directly to the various AliTracks to which the AliSignal object itself
1885 // is related (see AliTrack::AddSignal).
1886 // As such, the AliTrack destructor already takes care of clearing the corresponding
1887 // links from the various AliSignal slots for all the AliSignal objects that were
1888 // related to that AliTrack.
1889 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1890 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1891 // the AliSignal object when the corresponding AliTrack object is deleted.
1893 Int_t j=GetSlotIndex(name);
1894 if (j>0) ResetLinks(obj,j,k);
1896 ///////////////////////////////////////////////////////////////////////////
1897 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const
1899 // Provide the slot and position indices of all the storage locations
1900 // of the specified object.
1901 // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays
1902 // from which the (j,k) pairs can be obtained from the corresponding
1903 // array indices like (j,k)=(js.At(i),ks.At(i)).
1904 // The integer return argument represents the number of (j,k) pairs which
1905 // were encountered for the specified object.
1907 // If obj=0 no object selection is performed and all (j,k) indices
1908 // of the stored references for all objects are returned.
1912 // As usual the convention is that slot and position numbering starts at 1.
1914 // This memberfunction always resets the two TArrayI arrays at the start.
1916 // This memberfunction can only be used to obtain the (j,k) indices
1917 // of the object as stored via the SetLink() or AddLink() memberfunction.
1918 // This means that in case the user has entered a TObjArray as object
1919 // (to increase the dimension of the resulting structure), the (j,k)
1920 // indices of that TObjArray are obtained and NOT the indices of the
1921 // actual objects contained in that TObjArray structure.
1926 // Note : In the internal storage matrix slots=columns positions=rows
1927 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js);
1930 ///////////////////////////////////////////////////////////////////////////
1931 Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const
1933 // Provide the position indices of all the storage locations of the
1934 // specified object in the j-th slot of this AliSignal.
1935 // The position indices are returned in the TArrayI array.
1936 // The integer return argument represents the number of storage locations which
1937 // were encountered for the specified object in the j-th slot.
1939 // If obj=0 no object selection is performed and all position indices
1940 // of the stored references for all objects of the j-th slot are returned.
1942 // If j=0 all slots will be scanned and all position indices matching the
1943 // object selection are returned.
1944 // Note that in this case multiple appearances of the same position index
1945 // will only be recorded once in the returned TArrayI array.
1949 // As usual the convention is that slot and position numbering starts at 1.
1951 // This memberfunction always resets the TArrayI array at the start.
1953 // This memberfunction can only be used to obtain the position indices
1954 // of the object as stored via the SetLink() or AddLink() memberfunction.
1955 // This means that in case the user has entered a TObjArray as object
1956 // (to increase the dimension of the resulting structure), the position
1957 // indices of that TObjArray are obtained and NOT the indices of the
1958 // actual objects contained in that TObjArray structure.
1962 // Note : In the internal storage matrix slots=columns positions=rows
1963 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j);
1966 ///////////////////////////////////////////////////////////////////////////
1967 Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const
1969 // Provide the position indices of all the storage locations of the
1970 // specified object in the name-specified slot of this AliSignal.
1971 // The position indices are returned in the TArrayI array.
1972 // The integer return argument represents the number of storage locations which
1973 // were encountered for the specified object in the j-th slot.
1975 // If obj=0 no object selection is performed and all position indices
1976 // of the stored references for all objects of the j-th slot are returned.
1978 // This procedure involves a slot-index search based on the specified name
1979 // at each invokation. This may become slow in case many slots have been
1980 // defined and/or when this procedure is invoked many times.
1981 // In such cases it is preferable to use indexed addressing in the user code
1982 // either directly or via a few invokations of GetSlotIndex().
1984 Int_t j=GetSlotIndex(name);
1986 if (j>0) n=GetIndices(obj,j,ks);
1989 ///////////////////////////////////////////////////////////////////////////
1990 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const
1992 // Provide the slot indices of all the storage locations of the
1993 // specified object for the k-th position in this AliSignal.
1994 // The slot indices are returned in the TArrayI array.
1995 // The integer return argument represents the number of storage locations which
1996 // were encountered for the specified object in the k-th position.
1998 // If obj=0 no object selection is performed and all slot indices
1999 // of the stored references for all objects in the k-th position are returned.
2001 // If k=0 all positions will be scanned and all slot indices matching the
2002 // object selection are returned.
2003 // Note that in this case multiple appearances of the same slot index
2004 // will only be recorded once in the returned TArrayI array.
2008 // As usual the convention is that slot and position numbering starts at 1.
2010 // This memberfunction always resets the TArrayI array at the start.
2012 // This memberfunction can only be used to obtain the slot indices
2013 // of the object as stored via the SetLink() or AddLink() memberfunction.
2014 // This means that in case the user has entered a TObjArray as object
2015 // (to increase the dimension of the resulting structure), the slot
2016 // indices of that TObjArray are obtained and NOT the indices of the
2017 // actual objects contained in that TObjArray structure.
2021 // Note : In the internal storage matrix slots=columns positions=rows
2022 if (fLinks) nrefs=fLinks->GetIndices(obj,k,js);
2025 ///////////////////////////////////////////////////////////////////////////
2026 void AliSignal::SetSwapMode(Int_t swap)
2028 // Set swapmode flag for the internal link storage.
2029 // In case for the stored links the maximum slot number differs considerably
2030 // from the maximum position number, it might be more efficient
2031 // (w.r.t. memory usage and/or output file size) to internally store the
2032 // link reference matrix with the rows and colums swapped.
2033 // This swapping is only related with the internal storage and as such
2034 // is completely hidden for the user.
2035 // At invokation of this memberfunction the default argument is swap=1.
2037 // Note : The swap mode can only be set as long as no links are
2038 // stored in the AliSignal (i.e. a new instance of AliSignal
2039 // or after invokation of the Reset() or ResetLinks() function).
2041 if (!fLinks) fLinks=new AliObjMatrix();
2042 fLinks->SetSwapMode(swap);
2044 ///////////////////////////////////////////////////////////////////////////
2045 Int_t AliSignal::GetSwapMode() const
2047 // Provide swapmode flag of the link storage.
2049 if (fLinks) swap=fLinks->GetSwapMode();
2052 ///////////////////////////////////////////////////////////////////////////
2053 void AliSignal::SetDevice(TObject* dev)
2055 // Store the pointer to the device which owns this AliSignal object.
2056 // This memberfunction is meant for internal use in AliDevice.
2059 ///////////////////////////////////////////////////////////////////////////
2060 AliDevice* AliSignal::GetDevice() const
2062 // Provide the pointer to the device which owns this AliSignal object.
2063 return (AliDevice*)fDevice;
2065 ///////////////////////////////////////////////////////////////////////////
2066 void AliSignal::AddTrack(AliTrack& t,Int_t mode)
2068 // Relate an AliTrack object to this signal.
2069 // Only the pointer values are stored for (backward) reference, meaning
2070 // that the tracks of which the pointers are stored are NOT owned
2071 // by the AliSignal object.
2073 // mode = 0 : Only the reference to the specified track is stored in
2074 // the current signal, without storing the (backward) reference
2075 // to this signal into the AliTrack structure.
2076 // 1 : The (backward) reference to the current signal is also automatically
2077 // stored into the AliTrack (or derived) object specified in the
2080 // The default is mode=1.
2082 if (!fTracks) fTracks=new TObjArray(1);
2084 // Check if this track is already stored for this signal
2085 Int_t ntk=GetNtracks();
2086 for (Int_t i=0; i<ntk; i++)
2088 if (&t==fTracks->At(i)) return;
2092 if (mode==1) t.AddSignal(*this,0);
2094 ///////////////////////////////////////////////////////////////////////////
2095 void AliSignal::RemoveTrack(AliTrack& t,Int_t mode)
2097 // Remove related AliTrack object from this signal.
2098 // Also all references (if any) to this track in the slot links area
2101 // mode = 0 : All references to the specified track are removed from
2102 // the current signal, without removing the (backward) reference
2103 // to this signal from the AliTrack structure.
2104 // 1 : The (backward) reference to the current signal is also automatically
2105 // removed from the AliTrack (or derived) object specified in the
2108 // The default is mode=1.
2112 AliTrack* test=(AliTrack*)fTracks->Remove(&t);
2113 if (test) fTracks->Compress();
2118 if (mode==1) t.RemoveSignal(*this,0);
2120 ///////////////////////////////////////////////////////////////////////////
2121 void AliSignal::RemoveTracks(Int_t mode)
2123 // Remove all related AliTrack objects from this signal.
2124 // Also all references (if any) to the related tracks in the slot links area
2127 // mode = 0 : All track references are removed from the current signal,
2128 // without removing the (backward) references to this signal from
2129 // the corresponding AliTrack objects.
2130 // 1 : The (backward) references to the current signal are also automatically
2131 // removed from the corresponding AliTrack (or derived) objects.
2133 // The default is mode=1.
2135 if (!fTracks) return;
2137 Int_t ntk=GetNtracks();
2138 for (Int_t i=0; i<ntk; i++)
2140 AliTrack* tx=(AliTrack*)fTracks->At(i);
2144 if (mode==1) tx->RemoveSignal(*this,0);
2151 ///////////////////////////////////////////////////////////////////////////
2152 Int_t AliSignal::GetNtracks(AliTrack* t) const
2154 // Provide the number of related AliTracks.
2155 // In case an AliTrack pointer is specified as input argument,
2156 // the number returned will be the number of occurrences (i.e. 0 or 1)
2157 // for that specified track.
2158 // By default t=0, which implies that just the number of all associated
2159 // tracks will be returned.
2161 if (!fTracks) return 0;
2163 Int_t ntk=fTracks->GetEntries();
2167 for (Int_t i=0; i<ntk; i++)
2169 AliTrack* tx=(AliTrack*)fTracks->At(i);
2170 if (tx==t) return 1;
2175 ///////////////////////////////////////////////////////////////////////////
2176 AliTrack* AliSignal::GetTrack(Int_t j) const
2178 // Provide the related AliTrack number j.
2179 // Note : j=1 denotes the first track.
2181 if (!fTracks) return 0;
2183 if ((j >= 1) && (j <= GetNtracks()))
2185 return (AliTrack*)fTracks->At(j-1);
2189 cout << " *AliSignal* track number : " << j << " out of range."
2190 << " Ntk = " << GetNtracks() << endl;
2194 ///////////////////////////////////////////////////////////////////////////
2195 AliTrack* AliSignal::GetIdTrack(Int_t id) const
2197 // Return the track with user identifier "id" of this signal
2198 if (!fTracks) return 0;
2201 for (Int_t i=0; i<GetNtracks(); i++)
2203 tx=(AliTrack*)fTracks->At(i);
2204 if (id == tx->GetId()) return tx;
2206 return 0; // No matching id found
2208 ///////////////////////////////////////////////////////////////////////////
2209 TObject* AliSignal::Clone(const char* name) const
2211 // Make a deep copy of the current object and provide the pointer to the copy.
2212 // This memberfunction enables automatic creation of new objects of the
2213 // correct type depending on the object type, a feature which may be very useful
2214 // for containers when adding objects in case the container owns the objects.
2215 // This feature allows e.g. AliTrack to store either AliSignal objects or
2216 // objects derived from AliSignal via the AddSignal memberfunction, provided
2217 // these derived classes also have a proper Clone memberfunction.
2219 AliSignal* sig=new AliSignal(*this);
2222 if (strlen(name)) sig->SetName(name);
2226 ///////////////////////////////////////////////////////////////////////////