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.
24 // Signal positions (r) and reference frames (f) are specified via
25 // SetPosition(r,f) under the following conventions :
27 // f="car" ==> r is Cartesian (x,y,z)
28 // f="sph" ==> r is Spherical (r,theta,phi)
29 // f="cyl" ==> r is Cylindrical (rho,phi,z)
31 // The same holds for SetPositionErrors().
33 // All angles are in radians.
39 // s.SetName("Start counter");
40 // Float_t pos[3]={-1,25,7};
41 // Float_t err[3]={0.03,0.7,0.18};
42 // Float_t signal=120.8;
43 // Float_t error=1.73;
44 // Float_t offset=-12.78;
46 // s.SetPosition(pos,"car");
47 // s.SetPositionErrors(err,"car");
48 // s.SetSignal(signal);
49 // s.SetSignalError(error);
50 // s.SetOffset(offset);
52 // Float_t loc[3],dr[3],sigma;
53 // s.GetPosition(loc,"sph");
54 // s.GetPositionErrors(dr,"sph");
55 // Float_t adc=s.GetSignal();
56 // Float_t sigma=s.GetSignalError();
58 // AliSignal q; // In the example below a signal contains the
59 // // following data : timing, ADC and dE/dx
60 // q.SetNameTitle("Hybrid","Test for multiple signal data");
61 // q.SetPosition(pos,"car");
62 // q.SetPositionErrors(err,"car");
63 // signal=82.5; // e.g. signal time in ns
66 // q.SetSlotName("TOF");
67 // q.SetSignal(signal,1);
68 // q.SetSignalError(error,1);
69 // q.SetOffset(offset,1);
70 // signal=268.1; // e.g. ADC value of signal
73 // // Addressing via name specification instead of index
74 // q.SetSlotName("ADC");
75 // q.SetSignal(signal,"ADC");
76 // q.SetSignalError(error,"ADC");
77 // q.SetGain(gain,"ADC");
78 // signal=23.7; // e.g. corresponding dE/dx value
82 // q.SetSlotName("dE/dx");
83 // q.SetSignal(signal,3);
84 // q.SetSignalError(error,3);
85 // q.SetOffset(offset,3);
88 // Float_t dedx=q.GetSignal("dE/dx");
90 //--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht
91 //- Modified: NvE $Date$ UU-SAP Utrecht
92 ///////////////////////////////////////////////////////////////////////////
94 #include "AliSignal.h"
96 #include "Riostream.h"
98 ClassImp(AliSignal) // Class implementation to enable ROOT I/O
100 AliSignal::AliSignal() : TNamed(),AliPosition(),AliAttrib()
102 // Creation of an AliSignal object and initialisation of parameters.
103 // Several signal values (with errors) can be stored in different slots.
104 // If needed, the storage for values (and errors) will be expanded automatically
105 // when entering values and/or errors.
112 ///////////////////////////////////////////////////////////////////////////
113 AliSignal::~AliSignal()
115 // Destructor to delete dynamically allocated memory
133 // Remove this signal from all related tracks
134 for (Int_t i=1; i<=fLinks->GetNobjects(); i++)
136 TObject* obj=fLinks->GetObject(i);
138 if (obj->InheritsFrom("AliTrack"))
140 AliTrack* tx=(AliTrack*)obj;
141 tx->RemoveSignal(*this);
148 ///////////////////////////////////////////////////////////////////////////
149 AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s)
157 // Don't copy the owning device pointer for the copy
160 Int_t n=s.GetNvalues();
162 for (Int_t i=1; i<=n; i++)
169 for (Int_t j=1; j<=n; j++)
171 val=s.GetSignalError(j);
172 SetSignalError(val,j);
176 for (Int_t k=1; k<=n; k++)
178 TH1F* hist=s.GetWaveform(k);
179 if (hist) SetWaveform(hist,k);
185 n=s.GetIndices(dum,slotarr,posarr);
187 for (Int_t idx=0; idx<n; idx++)
189 slot=slotarr.At(idx);
191 TObject* obj=s.GetLink(slot,pos);
192 if (obj) SetLink(obj,slot,pos);
195 ///////////////////////////////////////////////////////////////////////////
196 void AliSignal::Reset(Int_t mode)
198 // Reset all signal and position values and errors to 0.
200 // mode = 0 Reset position and all signal values and their errors to 0.
201 // The waveform histograms are reset, but the calibration
202 // constants (i.e. gains and offsets) are kept.
203 // 1 Reset position and delete the signal and error storage arrays.
204 // Also the waveform histograms, gains and offset arrays are deleted.
206 // The default when invoking Reset() corresponds to mode=0.
208 // Note : In all cases the storage of the various links will be reset.
209 // The UniqueID, name and title will NOT be reset.
210 // In case the user wants to reset these attributes, this has to
211 // be done explicitly via the SET facilities.
213 // The usage of mode=0 allows to re-use the allocated memory for new
214 // signal (and error) values. This behaviour is preferable (i.e. faster)
215 // in case the various signals always contain the same number of values
216 // and have the same calibration constants.
217 // The usage of mode=1 is slower, but allows a more efficient memory
218 // occupation (and smaller output file size) in case the different
219 // signals have a variable number of values.
221 // For more specific actions see ResetPosition(), ResetSignals(),
222 // DeleteSignals(), ResetGain(), ResetOffset(), ResetLink(), ResetWaveform(),
223 // DeleteWaveform() and DeleteCalibrations().
226 if (mode<0 || mode>1)
228 cout << " *AliSignal::Reset* Invalid argument mode = " << mode << endl;
229 cout << " Default mode=0 will be used." << endl;
241 DeleteCalibrations();
244 if (fLinks) fLinks->Reset();
247 ///////////////////////////////////////////////////////////////////////////
248 void AliSignal::ResetSignals(Int_t mode)
250 // Reset various signal data according to user selection.
252 // mode = 0 Reset all signal values and their errors to 0.
253 // 1 Reset only signal values
254 // 2 Reset only signal errors
256 // The default when invoking ResetSignals() corresponds to mode=0.
258 // Irrespective of the mode, the waveform histograms are reset.
260 if (mode<0 || mode>2)
262 cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl;
263 cout << " Default mode=0 will be used." << endl;
267 if (fSignals && (mode==0 || mode==1))
269 for (Int_t i=0; i<fSignals->GetSize(); i++)
271 fSignals->AddAt(0,i);
275 if (fDsignals && (mode==0 || mode==2))
277 for (Int_t j=0; j<fDsignals->GetSize(); j++)
279 fDsignals->AddAt(0,j);
285 ///////////////////////////////////////////////////////////////////////////
286 void AliSignal::DeleteSignals(Int_t mode)
288 // Delete storage arrays of various signal data according to user selection.
290 // mode = 0 Delete arrays of both signal values and their errors.
291 // 1 Delete only signal values array
292 // 2 Delete only signal errors array
294 // The default when invoking DeleteSignals() corresponds to mode=0.
296 // Irrespective of the mode, the waveform histograms are deleted.
298 if (mode<0 || mode>2)
300 cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl;
301 cout << " Default mode=0 will be used." << endl;
305 if (fSignals && (mode==0 || mode==1))
311 if (fDsignals && (mode==0 || mode==2))
319 ///////////////////////////////////////////////////////////////////////////
320 void AliSignal::SetSignal(Double_t sig,Int_t j)
322 // Store signal value for the j-th (default j=1) slot.
323 // Note : The first signal slot is at j=1.
324 // In case the value of the index j exceeds the maximum number of reserved
325 // slots for signal values, the number of reserved slots for the
326 // signal values is increased automatically.
330 fSignals=new TArrayF(j);
334 Int_t size=fSignals->GetSize();
341 fSignals->AddAt(float(sig),j-1);
343 ///////////////////////////////////////////////////////////////////////////
344 void AliSignal::SetSignal(Double_t sig,TString name)
346 // Store signal value for the name-specified slot.
348 // This procedure involves a slot-index search based on the specified name
349 // at each invokation. This may become slow in case many slots have been
350 // defined and/or when this procedure is invoked many times.
351 // In such cases it is preferable to use indexed addressing in the user code
352 // either directly or via a few invokations of GetSlotIndex().
354 Int_t j=GetSlotIndex(name);
355 if (j>0) SetSignal(sig,j);
357 ///////////////////////////////////////////////////////////////////////////
358 void AliSignal::AddSignal(Double_t sig,Int_t j)
360 // Add value to the signal of the j-th (default j=1) slot.
361 // Note : The first signal slot is at j=1.
362 // In case the value of the index j exceeds the maximum number of reserved
363 // slots for signal values, the number of reserved slots for the
364 // signal values is increased automatically.
368 fSignals=new TArrayF(j);
372 Int_t size=fSignals->GetSize();
379 Float_t sum=(fSignals->At(j-1))+sig;
380 fSignals->AddAt(sum,j-1);
382 ///////////////////////////////////////////////////////////////////////////
383 void AliSignal::AddSignal(Double_t sig,TString name)
385 // Add value to the signal of the name-specified slot.
387 // This procedure involves a slot-index search based on the specified name
388 // at each invokation. This may become slow in case many slots have been
389 // defined and/or when this procedure is invoked many times.
390 // In such cases it is preferable to use indexed addressing in the user code
391 // either directly or via a few invokations of GetSlotIndex().
393 Int_t j=GetSlotIndex(name);
394 if (j>0) AddSignal(sig,j);
396 ///////////////////////////////////////////////////////////////////////////
397 Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const
399 // Provide signal value of the j-th (default j=1) slot.
400 // Note : The first signal slot is at j=1.
401 // In case no signal is present or the argument j is invalid, 0 is returned.
402 // The parameter "mode" allows for automatic gain etc... correction of the signal.
404 // mode = 0 : Just the j-th signal is returned.
405 // 1 : The j-th signal is corrected for the gain, offset, dead flag etc...
406 // In case the gain value was not set, gain=1 will be assumed.
407 // In case the gain value was 0, a signal value of 0 is returned.
408 // In case the offset value was not set, offset=0 will be assumed.
409 // In case the j-th slot was marked dead, 0 is returned.
411 // The corrected signal (sigc) is determined as follows :
413 // sigc=(signal/gain)-offset
415 // The default is mode=0.
422 if (j>0 && j<=(fSignals->GetSize()))
424 sig=fSignals->At(j-1);
426 if (mode==0) return sig;
428 // Correct the signal for the gain, offset, dead flag etc...
429 if (GetDeadValue(j)) return 0;
431 if (GetGainFlag(j)) gain=GetGain(j);
432 if (GetOffsetFlag(j)) offset=GetOffset(j);
436 sig=(sig/gain)-offset;
445 cout << " *AliSignal::GetSignal* Index j = " << j << " invalid." << endl;
450 ///////////////////////////////////////////////////////////////////////////
451 Float_t AliSignal::GetSignal(TString name,Int_t mode) const
453 // Provide signal value of the name-specified slot.
454 // In case no signal is present, 0 is returned.
455 // The parameter "mode" allows for automatic gain etc... correction of the signal.
457 // mode = 0 : Just the j-th signal is returned.
458 // 1 : The j-th signal is corrected for the gain, offset, dead flag etc...
459 // In case the gain value was not set, gain=1 will be assumed.
460 // In case the gain value was 0, a signal value of 0 is returned.
461 // In case the offset value was not set, offset=0 will be assumed.
462 // In case the j-th slot was marked dead, 0 is returned.
464 // The corrected signal (sigc) is determined as follows :
466 // sigc=(signal/gain)-offset
468 // The default is mode=0.
470 // This procedure involves a slot-index search based on the specified name
471 // at each invokation. This may become slow in case many slots have been
472 // defined and/or when this procedure is invoked many times.
473 // In such cases it is preferable to use indexed addressing in the user code
474 // either directly or via a few invokations of GetSlotIndex().
476 Int_t j=GetSlotIndex(name);
478 if (j>0) val=GetSignal(j,mode);
481 ///////////////////////////////////////////////////////////////////////////
482 void AliSignal::SetSignalError(Double_t dsig,Int_t j)
484 // Store error on the signal for the j-th (default j=1) slot.
485 // Note : The first signal slot is at j=1.
486 // In case the value of the index j exceeds the maximum number of reserved
487 // slots for signal error values, the number of reserved slots for the
488 // signal errors is increased automatically.
492 fDsignals=new TArrayF(j);
496 Int_t size=fDsignals->GetSize();
503 fDsignals->AddAt(float(dsig),j-1);
505 ///////////////////////////////////////////////////////////////////////////
506 void AliSignal::SetSignalError(Double_t dsig,TString name)
508 // Store error on the signal for the name-specified slot.
510 // This procedure involves a slot-index search based on the specified name
511 // at each invokation. This may become slow in case many slots have been
512 // defined and/or when this procedure is invoked many times.
513 // In such cases it is preferable to use indexed addressing in the user code
514 // either directly or via a few invokations of GetSlotIndex().
516 Int_t j=GetSlotIndex(name);
517 if (j>0) SetSignalError(dsig,j);
519 ///////////////////////////////////////////////////////////////////////////
520 Float_t AliSignal::GetSignalError(Int_t j) const
522 // Provide error on the signal of the j-th (default j=1) slot.
523 // Note : The first signal slot is at j=1.
524 // In case no signal is present or the argument j is invalid, 0 is returned.
528 if (j>0 && j<=(fDsignals->GetSize()))
530 err=fDsignals->At(j-1);
534 cout << " *AliSignal::GetSignalError* Index j = " << j << " invalid." << endl;
539 ///////////////////////////////////////////////////////////////////////////
540 Float_t AliSignal::GetSignalError(TString name) const
542 // Provide error on the signal of the name-specified slot.
544 // This procedure involves a slot-index search based on the specified name
545 // at each invokation. This may become slow in case many slots have been
546 // defined and/or when this procedure is invoked many times.
547 // In such cases it is preferable to use indexed addressing in the user code
548 // either directly or via a few invokations of GetSlotIndex().
550 Int_t j=GetSlotIndex(name);
552 if (j>0) val=GetSignalError(j);
555 ///////////////////////////////////////////////////////////////////////////
556 void AliSignal::Data(TString f) const
558 // Provide all signal information within the coordinate frame f.
560 const char* name=GetName();
561 const char* title=GetTitle();
563 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
564 if (strlen(name)) cout << " Name : " << name;
565 if (strlen(title)) cout << " Title : " << title;
571 const char* devname=fDevice->GetName();
572 const char* devtitle=fDevice->GetTitle();
573 cout << " Owned by device : " << fDevice->ClassName();
574 if (strlen(devname)) cout << " Name : " << devname;
575 if (strlen(devtitle)) cout << " Title : " << devtitle;
579 // Provide an overview of the stored waveforms
582 // Provide an overview of all the data and attribute slots
585 ///////////////////////////////////////////////////////////////////////////
586 void AliSignal::List(Int_t j) const
588 // Provide signal information for the j-th slot.
589 // The first slot is at j=1.
590 // In case j=0 (default) the data of all slots will be listed.
591 // In case j=-1 the data of all slots will be listed, but the header
592 // information will be suppressed.
596 cout << " *AliSignal::List* Invalid argument j = " << j << endl;
602 const char* name=GetName();
603 const char* title=GetTitle();
605 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
606 if (strlen(name)) cout << " Name : " << name;
607 if (strlen(title)) cout << " Title : " << title;
611 const char* devname=fDevice->GetName();
612 const char* devtitle=fDevice->GetTitle();
613 cout << " Owned by device : " << fDevice->ClassName();
614 if (strlen(devname)) cout << " Name : " << devname;
615 if (strlen(devtitle)) cout << " Title : " << devtitle;
620 Int_t nvalues=GetNvalues();
621 Int_t nerrors=GetNerrors();
623 if (fLinks) nlinkslots=fLinks->GetMaxColumn();
625 if (nerrors>n) n=nerrors;
626 if (nlinkslots>n) n=nlinkslots;
635 for (Int_t i=1; i<=n; i++)
637 cout << " Slot : " << i;
638 if (i<=nvalues) cout << " Signal value : " << GetSignal(i);
639 if (i<=nerrors) cout << " error : " << GetSignalError(i);
643 nrefs=GetIndices(obj,i,posarr);
644 for (Int_t k=0; k<nrefs; k++)
650 cout << " Link at position " << pos << " to : " << obj->ClassName();
651 if (obj->InheritsFrom("TNamed"))
653 const char* lname=obj->GetName();
654 const char* ltitle=obj->GetTitle();
655 if (strlen(lname)) cout << " Name : " << lname;
656 if (strlen(ltitle)) cout << " Title : " << ltitle;
667 cout << " Slot : " << j;
668 if (j<=nvalues) cout << " Signal value : " << GetSignal(j);
669 if (j<=nerrors) cout << " error : " << GetSignalError(j);
673 nrefs=GetIndices(obj,j,posarr);
674 for (Int_t kj=0; kj<nrefs; kj++)
680 cout << " Link at position " << pos << " to : " << obj->ClassName();
681 if (obj->InheritsFrom("TNamed"))
683 const char* lnamej=obj->GetName();
684 const char* ltitlej=obj->GetTitle();
685 if (strlen(lnamej)) cout << " Name : " << lnamej;
686 if (strlen(ltitlej)) cout << " Title : " << ltitlej;
694 ///////////////////////////////////////////////////////////////////////////
695 void AliSignal::List(TString name) const
697 // Provide signal information for the name-specified slot.
699 // This procedure involves a slot-index search based on the specified name
700 // at each invokation. This may become slow in case many slots have been
701 // defined and/or when this procedure is invoked many times.
702 // In such cases it is preferable to use indexed addressing in the user code
703 // either directly or via a few invokations of GetSlotIndex().
705 Int_t j=GetSlotIndex(name);
708 ///////////////////////////////////////////////////////////////////////////
709 void AliSignal::ListWaveform(Int_t j) const
711 // Provide information for the j-th waveform.
712 // The first waveform is at j=1.
713 // In case j=0 (default) the info of all waveforms will be listed.
714 // In case j=-1 the info of all waveforms will be listed, but the header
715 // information will be suppressed.
719 cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl;
725 const char* name=GetName();
726 const char* title=GetTitle();
728 cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
729 if (strlen(name)) cout << " Name : " << name;
730 if (strlen(title)) cout << " Title : " << title;
734 const char* devname=fDevice->GetName();
735 const char* devtitle=fDevice->GetTitle();
736 cout << " Owned by device : " << fDevice->ClassName();
737 if (strlen(devname)) cout << " Name : " << devname;
738 if (strlen(devtitle)) cout << " Title : " << devtitle;
743 Int_t n=GetNwaveforms();
748 for (Int_t i=1; i<=n; i++)
753 const char* wfname=obj->GetName();
754 const char* wftitle=obj->GetTitle();
755 cout << " Waveform " << i << " : " << obj->ClassName();
756 if (strlen(wfname)) cout << " Name : " << wfname;
757 if (strlen(wftitle)) cout << " Title : " << wftitle;
769 const char* wfnamej=obj->GetName();
770 const char* wftitlej=obj->GetTitle();
771 cout << " Waveform " << j << " : " << obj->ClassName();
772 if (strlen(wfnamej)) cout << " Name : " << wfnamej;
773 if (strlen(wftitlej)) cout << " Title : " << wftitlej;
779 ///////////////////////////////////////////////////////////////////////////
780 Int_t AliSignal::GetNvalues() const
782 // Provide the number of values for this signal.
784 if (fSignals) n=fSignals->GetSize();
787 ///////////////////////////////////////////////////////////////////////////
788 Int_t AliSignal::GetNerrors() const
790 // Provide the number specified errors on the values for this signal.
792 if (fDsignals) n=fDsignals->GetSize();
795 ///////////////////////////////////////////////////////////////////////////
796 Int_t AliSignal::GetNwaveforms() const
798 // Provide the number of specified waveforms for this signal.
799 // Actually the return value is the highest index of the stored waveforms.
800 // This allows an index dependent meaning of waveform info (e.g. waveforms
801 // with various gain values).
802 // So, when all waveforms are stored in consequetive positions (e.g. 1,2,3),
803 // this memberfunction returns 3, being both the highest filled position
804 // and the actual number of waveforms.
805 // In case only waveforms are stored at positions 1,2,5,7 this memberfunction
806 // returns a value 7 whereas only 4 actual waveforms are present.
807 // This implies that when looping over the various waveform slots, one
808 // always has to check whether the returned pointer value is non-zero
809 // (which is a good practice anyhow).
811 if (fWaveforms) n=fWaveforms->GetLast();
814 ///////////////////////////////////////////////////////////////////////////
815 TH1F* AliSignal::GetWaveform(Int_t j) const
817 // Provide pointer to the j-th waveform histogram.
819 if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1);
822 ///////////////////////////////////////////////////////////////////////////
823 TH1F* AliSignal::GetWaveform(TString name) const
825 // Provide pointer to the waveform histogram with the specified name.
826 // In case no match is found, zero is returned.
827 Int_t n=GetNwaveforms();
829 for (Int_t i=1; i<=n; i++)
831 TH1F* waveform=GetWaveform(i);
834 str=waveform->GetName();
835 if (str == name) return waveform;
838 return 0; // No match found
840 ///////////////////////////////////////////////////////////////////////////
841 Int_t AliSignal::GetWaveformIndex(TString name) const
843 // Provide index to the waveform histogram with the specified name.
844 // In case no match is found, zero is returned.
845 Int_t n=GetNwaveforms();
847 for (Int_t i=1; i<=n; i++)
849 TH1F* waveform=GetWaveform(i);
852 str=waveform->GetName();
853 if (str == name) return i;
856 return 0; // No match found
858 ///////////////////////////////////////////////////////////////////////////
859 void AliSignal::SetWaveform(TH1F* waveform,Int_t j)
861 // Set the 1D waveform histogram for the j-th waveform.
864 // The first waveform position at j=1.
865 // j=1 is the default value.
867 // In case the value of the index j exceeds the maximum number of reserved
868 // positions for the waveforms, the number of reserved positions for the waveforms
869 // is increased automatically.
871 // In case the histo pointer argument has the same value as the current waveform
872 // histogram pointer value, no action is taken since the user has already
873 // modified the actual histogram.
875 // In case the histo pointer argument is zero, the current waveform histogram
876 // is deleted and the pointer set to zero.
878 // In all other cases the current waveform histogram is deleted and a new
879 // copy of the input histogram is created which becomes the current waveform
886 fWaveforms=new TObjArray(j);
887 fWaveforms->SetOwner();
890 if (j > fWaveforms->GetSize()) fWaveforms->Expand(j);
892 TH1F* hcur=(TH1F*)fWaveforms->At(j-1);
893 if (waveform != hcur)
897 fWaveforms->Remove(hcur);
903 hcur=new TH1F(*waveform);
904 fWaveforms->AddAt(hcur,j-1);
908 ///////////////////////////////////////////////////////////////////////////
909 void AliSignal::ResetWaveform(Int_t j)
911 // Reset the histogram of the j-th (default j=1) waveform.
912 // This memberfunction invokes TH1F::Reset() for the corresponding waveform(s).
913 // To actually delete the histograms from memory, use DeleteWaveform().
914 // Notes : The first position is at j=1.
915 // j=0 ==> All waveforms will be reset.
917 if (!fWaveforms) return;
919 Int_t size=fWaveforms->GetSize();
921 if ((j>=0) && (j<=size))
925 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
926 if (hwave) hwave->Reset();
930 for (Int_t i=0; i<size; i++)
932 TH1F* hwave=(TH1F*)fWaveforms->At(i);
933 if (hwave) hwave->Reset();
939 cout << " *AliSignal::ResetWaveform* Index j = " << j << " invalid." << endl;
943 ///////////////////////////////////////////////////////////////////////////
944 void AliSignal::ResetWaveform(TString name)
946 // Reset the waveform with the specified name.
947 Int_t j=GetWaveformIndex(name);
948 if (j>0) ResetWaveform(j);
950 ///////////////////////////////////////////////////////////////////////////
951 void AliSignal::DeleteWaveform(Int_t j)
953 // Delete the histogram of the j-th (default j=1) waveform.
954 // Notes : The first position is at j=1.
955 // j=0 ==> All waveforms will be deleted.
957 if (!fWaveforms) return;
959 Int_t size=fWaveforms->GetSize();
961 if ((j>=0) && (j<=size))
965 TH1F* hwave=(TH1F*)fWaveforms->At(j-1);
968 fWaveforms->Remove(hwave);
980 cout << " *AliSignal::DeleteWaveform* Index j = " << j << " invalid." << endl;
984 ///////////////////////////////////////////////////////////////////////////
985 void AliSignal::DeleteWaveform(TString name)
987 // Delete the waveform with the specified name.
988 Int_t j=GetWaveformIndex(name);
989 if (j>0) DeleteWaveform(j);
991 ///////////////////////////////////////////////////////////////////////////
992 Int_t AliSignal::GetNlinks(TObject* obj,Int_t j) const
994 // Provide the number of links to the specified object for the j-th slot.
995 // If j=0 (default) all slots will be scanned for the specified object.
996 // If obj=0 (default) all encountered objects for the specified slot will be counted.
997 // So, invokation of the default GetNlinks() will return the total number of
998 // all references to all sorts of stored objects.
1001 cout << " *AliSignal::GetNlinks* Index j = " << j << " invalid." << endl;
1008 if (fLinks) n=fLinks->GetNrefs(obj);
1013 n=GetIndices(obj,j,posarr);
1017 ///////////////////////////////////////////////////////////////////////////
1018 Int_t AliSignal::GetNlinks(TObject* obj,TString name) const
1020 // Provide the number of links to the specified object for the name-spec. slot.
1021 // If obj=0 all encountered objects for the specified slot will be counted.
1023 // This procedure involves a slot-index search based on the specified name
1024 // at each invokation. This may become slow in case many slots have been
1025 // defined and/or when this procedure is invoked many times.
1026 // In such cases it is preferable to use indexed addressing in the user code
1027 // either directly or via a few invokations of GetSlotIndex().
1029 Int_t j=GetSlotIndex(name);
1031 if (j>0) n=GetNlinks(obj,j);
1034 ///////////////////////////////////////////////////////////////////////////
1035 TObject* AliSignal::GetLink(Int_t j,Int_t k) const
1037 // Provide pointer of the object linked to the j-th slot at position k.
1040 // Note : In the internal storage matrix slots=columns positions=rows
1041 if (fLinks) obj=fLinks->GetObject(k,j);
1044 ///////////////////////////////////////////////////////////////////////////
1045 TObject* AliSignal::GetLink(TString name,Int_t k) const
1047 // Provide pointer of the object linked to the name-spec. slot at position k.
1049 // This procedure involves a slot-index search based on the specified name
1050 // at each invokation. This may become slow in case many slots have been
1051 // defined and/or when this procedure is invoked many times.
1052 // In such cases it is preferable to use indexed addressing in the user code
1053 // either directly or via a few invokations of GetSlotIndex().
1055 Int_t j=GetSlotIndex(name);
1057 if (j>0) obj=GetLink(j,k);
1060 ///////////////////////////////////////////////////////////////////////////
1061 void AliSignal::SetLink(TObject* obj,Int_t j,Int_t k)
1063 // Introduce a link (=pointer) to an object for the j-th slot at position k.
1064 // Only the pointer values are stored for (backward) reference, meaning
1065 // that the objects of which the pointers are stored are NOT owned
1066 // by the AliSignal object.
1069 // The first slot is at j=1 and the first position is at k=1.
1070 // j=1 and k=1 are the default values.
1072 // If needed, the storage area for the links is increased automatically.
1074 // In case the pointer argument is zero, indeed a value of zero will be
1075 // stored at the specified position (k) for the specified slot (j).
1077 // In principle any object derived from TObject can be referred to by this
1079 // However, this "linking back" facility was introduced to enable AliSignal slots
1080 // to refer directly to the various AliTracks to which the AliSignal object itself
1081 // is related (see AliTrack::AddSignal).
1082 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1083 // object, the current signal is automatically related to this AliTrack
1084 // (or derived) object.
1086 // Please also have a look at the docs of the memberfunction ResetLink()
1087 // to prevent the situation of stored pointers to non-existent object.
1089 if (!fLinks && obj) fLinks=new AliObjMatrix();
1091 if (!fLinks) return;
1093 // Note : In the internal storage matrix slots=columns positions=rows
1094 fLinks->EnterObject(k,j,obj);
1097 if (obj->InheritsFrom("AliTrack"))
1099 AliTrack* t=(AliTrack*)obj;
1100 t->AddSignal(*this);
1104 ///////////////////////////////////////////////////////////////////////////
1105 void AliSignal::SetLink(TObject* obj,TString name,Int_t k)
1107 // Introduce a link (=pointer) to an object for the name-spec. slot at position k.
1108 // Only the pointer values are stored for (backward) reference, meaning
1109 // that the objects of which the pointers are stored are NOT owned
1110 // by the AliSignal object.
1112 // This procedure involves a slot-index search based on the specified name
1113 // at each invokation. This may become slow in case many slots have been
1114 // defined and/or when this procedure is invoked many times.
1115 // In such cases it is preferable to use indexed addressing in the user code
1116 // either directly or via a few invokations of GetSlotIndex().
1118 Int_t j=GetSlotIndex(name);
1119 if (j>0) SetLink(obj,j,k);
1121 ///////////////////////////////////////////////////////////////////////////
1122 void AliSignal::AddLink(TObject* obj,Int_t j)
1124 // Introduce a link (=pointer) to an object for the j-th slot at the first
1126 // Only the pointer values are stored for (backward) reference, meaning
1127 // that the objects of which the pointers are stored are NOT owned
1128 // by the AliSignal object.
1131 // The first slot is at j=1 and the first position is at k=1.
1132 // j=1 is the default value.
1134 // If needed, the storage area for the links is increased automatically.
1136 // In case the pointer argument is zero, no link will be added.
1138 // In principle any object derived from TObject can be referred to by this
1140 // However, this "linking back" facility was introduced to enable AliSignal slots
1141 // to refer directly to the various AliTracks to which the AliSignal object itself
1142 // is related (see AliTrack::AddSignal).
1143 // Therefore, in case the input argument "obj" points to an AliTrack (or derived)
1144 // object, the current signal is automatically related to this AliTrack
1145 // (or derived) object.
1147 // Please also have a look at the docs of the memberfunction ResetLink()
1148 // to prevent the situation of stored pointers to non-existent object.
1150 if (!obj || j<=0) return;
1152 if (!fLinks) fLinks=new AliObjMatrix();
1155 Int_t n=GetNlinks(dum,j);
1157 for (Int_t k=1; k<=n; k++)
1166 ///////////////////////////////////////////////////////////////////////////
1167 void AliSignal::AddLink(TObject* obj,TString name)
1169 // Introduce a link (=pointer) to an object for the name-spec slot at the first
1171 // Only the pointer values are stored for (backward) reference, meaning
1172 // that the objects of which the pointers are stored are NOT owned
1173 // by the AliSignal object.
1175 // This procedure involves a slot-index search based on the specified name
1176 // at each invokation. This may become slow in case many slots have been
1177 // defined and/or when this procedure is invoked many times.
1178 // In such cases it is preferable to use indexed addressing in the user code
1179 // either directly or via a few invokations of GetSlotIndex().
1181 Int_t j=GetSlotIndex(name);
1182 if (j>0) AddLink(obj,j);
1184 ///////////////////////////////////////////////////////////////////////////
1185 void AliSignal::ResetLink(Int_t j,Int_t k)
1187 // Reset the link of the j-th slot at position k.
1190 // The first slot is at j=1 and the first position is at k=1.
1191 // j=1 and k=1 are the default values.
1193 // This memberfunction is intended to reset only 1 specified link location.
1194 // For extended functionality, please refer to the memberfuction ResetLinks().
1196 // In general the user should take care of properly clearing the corresponding
1197 // pointer here when the referred object is deleted.
1198 // However, this "linking back" facility was introduced to enable AliSignal slots
1199 // to refer directly to the various AliTracks to which the AliSignal object itself
1200 // is related (see AliTrack::AddSignal).
1201 // As such, the AliTrack destructor already takes care of clearing the corresponding
1202 // links from the various AliSignal slots for all the AliSignal objects that were
1203 // related to that AliTrack.
1204 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1205 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1206 // the AliSignal object when the corresponding AliTrack object is deleted.
1208 // Note : In the internal storage matrix slots=columns positions=rows
1209 if (fLinks) fLinks->RemoveObject(k,j);
1211 ///////////////////////////////////////////////////////////////////////////
1212 void AliSignal::ResetLink(TString name,Int_t k)
1214 // Reset the link of the name-specified slot at position k.
1216 // This memberfunction is intended to reset only 1 specified link location.
1217 // For extended functionality, please refer to the memberfuction ResetLinks().
1219 // This procedure involves a slot-index search based on the specified name
1220 // at each invokation. This may become slow in case many slots have been
1221 // defined and/or when this procedure is invoked many times.
1222 // In such cases it is preferable to use indexed addressing in the user code
1223 // either directly or via a few invokations of GetSlotIndex().
1225 Int_t j=GetSlotIndex(name);
1226 if (j>0) ResetLink(j,k);
1228 ///////////////////////////////////////////////////////////////////////////
1229 void AliSignal::ResetLinks(TObject* obj,Int_t j,Int_t k)
1231 // Reset single or multiple link(s) according to user specified selections.
1233 // A link is only reset if the stored reference matches the argument "obj".
1234 // In case obj=0 no check on the matching of the stored reference is performed
1235 // and the stored link is always reset in accordance with the other
1236 // selection criteria.
1238 // In case the slot argument "j" is specified, only the links from that
1239 // specified slot will be deleted.
1240 // In case j=0 (default) no checking on the slot index is performed.
1242 // In case the position argument "k" is specified, only the links from that
1243 // specified position will be deleted.
1244 // In case k=0 (default) no checking on the position index is performed.
1246 // So, invokation of ResetLinks(obj) will remove all references to the
1247 // object "obj" from the total AliSignal, whereas ResetLinks(obj,j)
1248 // will remove all references to the object "obj" only from slot "j".
1252 // The first slot is indicated as j=1, whereas the first position is at k=1.
1254 // Invokation of ResetLinks(0,row,col) is equivalent to invoking the
1255 // memberfunction ResetLink(row,col).
1256 // Invoking the latter directly is slightly faster.
1258 // Invokation of ResetLinks(0) will reset all stored references in this AliSignal.
1260 // In general the user should take care of properly clearing the corresponding
1261 // pointer here when the referred object is deleted.
1262 // However, this "linking back" facility was introduced to enable AliSignal slots
1263 // to refer directly to the various AliTracks to which the AliSignal object itself
1264 // is related (see AliTrack::AddSignal).
1265 // As such, the AliTrack destructor already takes care of clearing the corresponding
1266 // links from the various AliSignal slots for all the AliSignal objects that were
1267 // related to that AliTrack.
1268 // So, in case the link introduced via SetLink() is the pointer of an AliTrack object,
1269 // the user doesn't have to worry about clearing the corresponding AliTrack link from
1270 // the AliSignal object when the corresponding AliTrack object is deleted.
1272 if (!fLinks) return;
1274 if (!obj && !j && !k)
1280 // Note : In the internal storage matrix slots=columns positions=rows
1281 fLinks->RemoveObjects(obj,k,j);
1284 ///////////////////////////////////////////////////////////////////////////
1285 void AliSignal::ResetLinks(TObject* obj,TString name,Int_t k)
1287 // Reset single or multiple link(s) according to user specified selections.
1289 // A link is only reset if the stored reference matches the argument "obj".
1290 // In case obj=0 no check on the matching of the stored reference is performed
1291 // and the stored link is always reset in accordance with the other
1292 // selection criteria.
1294 // In case the position argument "k" is specified, only the links from that
1295 // specified position will be deleted.
1296 // In case k=0 (default) no checking on the position index is performed.
1298 // This procedure involves a slot-index search based on the specified name
1299 // at each invokation. This may become slow in case many slots have been
1300 // defined and/or when this procedure is invoked many times.
1301 // In such cases it is preferable to use indexed addressing in the user code
1302 // either directly or via a few invokations of GetSlotIndex().
1304 Int_t j=GetSlotIndex(name);
1305 if (j>0) ResetLinks(obj,j,k);
1307 ///////////////////////////////////////////////////////////////////////////
1308 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,TArrayI& ks) const
1310 // Provide the slot and position indices of all the storage locations
1311 // of the specified object.
1312 // The slot (j) and pos. (k) indices are returned in the two separate TArrayI arrays
1313 // from which the (j,k) pairs can be obtained from the corresponding
1314 // array indices like (j,k)=(js.At(i),ks.At(i)).
1315 // The integer return argument represents the number of (j,k) pairs which
1316 // were encountered for the specified object.
1318 // If obj=0 no object selection is performed and all (j,k) indices
1319 // of the stored references for all objects are returned.
1323 // As usual the convention is that slot and position numbering starts at 1.
1325 // This memberfunction always resets the two TArrayI arrays at the start.
1327 // This memberfunction can only be used to obtain the (j,k) indices
1328 // of the object as stored via the SetLink() or AddLink() memberfunction.
1329 // This means that in case the user has entered a TObjArray as object
1330 // (to increase the dimension of the resulting structure), the (j,k)
1331 // indices of that TObjArray are obtained and NOT the indices of the
1332 // actual objects contained in that TObjArray structure.
1337 // Note : In the internal storage matrix slots=columns positions=rows
1338 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,js);
1341 ///////////////////////////////////////////////////////////////////////////
1342 Int_t AliSignal::GetIndices(TObject* obj,Int_t j,TArrayI& ks) const
1344 // Provide the position indices of all the storage locations of the
1345 // specified object in the j-th slot of this AliSignal.
1346 // The position indices are returned in the TArrayI array.
1347 // The integer return argument represents the number of storage locations which
1348 // were encountered for the specified object in the j-th slot.
1350 // If obj=0 no object selection is performed and all position indices
1351 // of the stored references for all objects of the j-th slot are returned.
1353 // If j=0 all slots will be scanned and all position indices matching the
1354 // object selection are returned.
1355 // Note that in this case multiple appearances of the same position index
1356 // will only be recorded once in the returned TArrayI array.
1360 // As usual the convention is that slot and position numbering starts at 1.
1362 // This memberfunction always resets the TArrayI array at the start.
1364 // This memberfunction can only be used to obtain the position indices
1365 // of the object as stored via the SetLink() or AddLink() memberfunction.
1366 // This means that in case the user has entered a TObjArray as object
1367 // (to increase the dimension of the resulting structure), the position
1368 // indices of that TObjArray are obtained and NOT the indices of the
1369 // actual objects contained in that TObjArray structure.
1373 // Note : In the internal storage matrix slots=columns positions=rows
1374 if (fLinks) nrefs=fLinks->GetIndices(obj,ks,j);
1377 ///////////////////////////////////////////////////////////////////////////
1378 Int_t AliSignal::GetIndices(TObject* obj,TString name,TArrayI& ks) const
1380 // Provide the position indices of all the storage locations of the
1381 // specified object in the name-specified slot of this AliSignal.
1382 // The position indices are returned in the TArrayI array.
1383 // The integer return argument represents the number of storage locations which
1384 // were encountered for the specified object in the j-th slot.
1386 // If obj=0 no object selection is performed and all position indices
1387 // of the stored references for all objects of the j-th slot are returned.
1389 // This procedure involves a slot-index search based on the specified name
1390 // at each invokation. This may become slow in case many slots have been
1391 // defined and/or when this procedure is invoked many times.
1392 // In such cases it is preferable to use indexed addressing in the user code
1393 // either directly or via a few invokations of GetSlotIndex().
1395 Int_t j=GetSlotIndex(name);
1397 if (j>0) n=GetIndices(obj,j,ks);
1400 ///////////////////////////////////////////////////////////////////////////
1401 Int_t AliSignal::GetIndices(TObject* obj,TArrayI& js,Int_t k) const
1403 // Provide the slot indices of all the storage locations of the
1404 // specified object for the k-th position in this AliSignal.
1405 // The slot indices are returned in the TArrayI array.
1406 // The integer return argument represents the number of storage locations which
1407 // were encountered for the specified object in the k-th position.
1409 // If obj=0 no object selection is performed and all slot indices
1410 // of the stored references for all objects in the k-th position are returned.
1412 // If k=0 all positions will be scanned and all slot indices matching the
1413 // object selection are returned.
1414 // Note that in this case multiple appearances of the same slot index
1415 // will only be recorded once in the returned TArrayI array.
1419 // As usual the convention is that slot and position numbering starts at 1.
1421 // This memberfunction always resets the TArrayI array at the start.
1423 // This memberfunction can only be used to obtain the slot indices
1424 // of the object as stored via the SetLink() or AddLink() memberfunction.
1425 // This means that in case the user has entered a TObjArray as object
1426 // (to increase the dimension of the resulting structure), the slot
1427 // indices of that TObjArray are obtained and NOT the indices of the
1428 // actual objects contained in that TObjArray structure.
1432 // Note : In the internal storage matrix slots=columns positions=rows
1433 if (fLinks) nrefs=fLinks->GetIndices(obj,k,js);
1436 ///////////////////////////////////////////////////////////////////////////
1437 void AliSignal::SetSwapMode(Int_t swap)
1439 // Set swapmode flag for the internal link storage.
1440 // In case for the stored links the maximum slot number differs considerably
1441 // from the maximum position number, it might be more efficient
1442 // (w.r.t. memory usage and/or output file size) to internally store the
1443 // link reference matrix with the rows and colums swapped.
1444 // This swapping is only related with the internal storage and as such
1445 // is completely hidden for the user.
1446 // At invokation of this memberfunction the default argument is swap=1.
1448 // Note : The swap mode can only be set as long as no links are
1449 // stored in the AliSignal (i.e. a new instance of AliSignal
1450 // or after invokation of the Reset() or ResetLinks() function).
1452 if (!fLinks) fLinks=new AliObjMatrix();
1453 fLinks->SetSwapMode(swap);
1455 ///////////////////////////////////////////////////////////////////////////
1456 Int_t AliSignal::GetSwapMode() const
1458 // Provide swapmode flag of the link storage.
1460 if (fLinks) swap=fLinks->GetSwapMode();
1463 ///////////////////////////////////////////////////////////////////////////
1464 void AliSignal::SetDevice(TObject* dev)
1466 // Store the pointer to the device which owns this AliSignal object.
1467 // This memberfunction is meant for internal use in AliDevice.
1470 ///////////////////////////////////////////////////////////////////////////
1471 AliDevice* AliSignal::GetDevice() const
1473 // Provide the pointer to the device which owns this AliSignal object.
1474 return (AliDevice*)fDevice;
1476 ///////////////////////////////////////////////////////////////////////////
1477 TObject* AliSignal::Clone(const char* name) const
1479 // Make a deep copy of the current object and provide the pointer to the copy.
1480 // This memberfunction enables automatic creation of new objects of the
1481 // correct type depending on the object type, a feature which may be very useful
1482 // for containers when adding objects in case the container owns the objects.
1483 // This feature allows e.g. AliTrack to store either AliSignal objects or
1484 // objects derived from AliSignal via the AddSignal memberfunction, provided
1485 // these derived classes also have a proper Clone memberfunction.
1487 AliSignal* sig=new AliSignal(*this);
1490 if (strlen(name)) sig->SetName(name);
1494 ///////////////////////////////////////////////////////////////////////////