//
// AliSignal q; // In the example below a signal contains the
// // following data : timing, ADC and dE/dx
-// q.SetName("TOF hit");
+// q.SetNameTitle("Hybrid","Test for multiple signal data");
// q.SetPosition(pos,"car");
// q.SetPositionErrors(err,"car");
// signal=82.5; // e.g. signal time in ns
// error=2.01;
// offset=0.003;
+// q.SetSlotName("TOF");
// q.SetSignal(signal,1);
// q.SetSignalError(error,1);
// q.SetOffset(offset,1);
// signal=268.1; // e.g. ADC value of signal
// error=3.75;
// gain=120.78;
-// q.SetSignal(signal,2);
-// q.SetSignalError(error,2);
-// q.SetGain(gain,2);
+// // Addressing via name specification instead of index
+// q.SetSlotName("ADC");
+// q.SetSignal(signal,"ADC");
+// q.SetSignalError(error,"ADC");
+// q.SetGain(gain,"ADC");
// signal=23.7; // e.g. corresponding dE/dx value
// error=0.48;
// offset=0.2;
// gain=150;
+// q.SetSlotName("dE/dx");
// q.SetSignal(signal,3);
// q.SetSignalError(error,3);
// q.SetOffset(offset,3);
// q.SetGain(gain,3);
//
+// Float_t dedx=q.GetSignal("dE/dx");
+//
//--- Author: Nick van Eijndhoven 23-jan-1999 UU-SAP Utrecht
//- Modified: NvE $Date$ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
fDsignals=0;
fWaveforms=0;
fLinks=0;
+ fDevice=0;
}
///////////////////////////////////////////////////////////////////////////
AliSignal::~AliSignal()
fWaveforms=0;
fLinks=0;
+ // Don't copy the owning device pointer for the copy
+ fDevice=0;
+
Int_t n=s.GetNvalues();
Double_t val;
for (Int_t i=1; i<=n; i++)
// The default when invoking Reset() corresponds to mode=0.
//
// Note : In all cases the storage of the various links will be reset.
+// The UniqueID, name and title will NOT be reset.
+// In case the user wants to reset these attributes, this has to
+// be done explicitly via the SET facilities.
//
// The usage of mode=0 allows to re-use the allocated memory for new
// signal (and error) values. This behaviour is preferable (i.e. faster)
}
if (fLinks) fLinks->Reset();
+ fDevice=0;
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::ResetSignals(Int_t mode)
const char* name=GetName();
const char* title=GetTitle();
- cout << " *" << ClassName() << "::Data*";
+ cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
if (strlen(name)) cout << " Name : " << name;
if (strlen(title)) cout << " Title : " << title;
cout << endl;
cout << " Position";
Ali3Vector::Data(f);
+ if (fDevice)
+ {
+ const char* devname=fDevice->GetName();
+ const char* devtitle=fDevice->GetTitle();
+ cout << " Owned by device : " << fDevice->ClassName();
+ if (strlen(devname)) cout << " Name : " << devname;
+ if (strlen(devtitle)) cout << " Title : " << devtitle;
+ cout << endl;
+ }
+ // Provide an overview of the stored waveforms
+ ListWaveform(-1);
+
+ // Provide an overview of all the data and attribute slots
List(-1);
}
///////////////////////////////////////////////////////////////////////////
const char* name=GetName();
const char* title=GetTitle();
- cout << " *" << ClassName() << "::Data*";
+ cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
if (strlen(name)) cout << " Name : " << name;
if (strlen(title)) cout << " Title : " << title;
cout << endl;
+ if (fDevice)
+ {
+ const char* devname=fDevice->GetName();
+ const char* devtitle=fDevice->GetTitle();
+ cout << " Owned by device : " << fDevice->ClassName();
+ if (strlen(devname)) cout << " Name : " << devname;
+ if (strlen(devtitle)) cout << " Title : " << devtitle;
+ cout << endl;
+ }
}
Int_t nvalues=GetNvalues();
Int_t nerrors=GetNerrors();
- Int_t nwforms=GetNwaveforms();
Int_t nlinkslots=0;
if (fLinks) nlinkslots=fLinks->GetMaxColumn();
Int_t n=nvalues;
if (nerrors>n) n=nerrors;
- if (nwforms>n) n=nwforms;
if (nlinkslots>n) n=nlinkslots;
TObject* obj=0;
if (i<=nerrors) cout << " error : " << GetSignalError(i);
AliAttrib::List(i);
cout << endl;
- obj=GetWaveform(i);
- if (obj)
- {
- const char* wfname=obj->GetName();
- const char* wftitle=obj->GetTitle();
- cout << " Waveform : " << obj->ClassName();
- if (strlen(wfname)) cout << " Name : " << wfname;
- if (strlen(wftitle)) cout << " Title : " << wftitle;
- cout << endl;
- }
obj=0;
nrefs=GetIndices(obj,i,posarr);
for (Int_t k=0; k<nrefs; k++)
if (j<=nerrors) cout << " error : " << GetSignalError(j);
AliAttrib::List(j);
cout << endl;
- obj=GetWaveform(j);
- if (obj)
- {
- const char* wfnamej=obj->GetName();
- const char* wftitlej=obj->GetTitle();
- cout << " Waveform : " << obj->ClassName();
- if (strlen(wfnamej)) cout << " Name : " << wfnamej;
- if (strlen(wftitlej)) cout << " Title : " << wftitlej;
- cout << endl;
- }
obj=0;
nrefs=GetIndices(obj,j,posarr);
for (Int_t kj=0; kj<nrefs; kj++)
if (j>0) List(j);
}
///////////////////////////////////////////////////////////////////////////
+void AliSignal::ListWaveform(Int_t j) const
+{
+// Provide information for the j-th waveform.
+// The first waveform is at j=1.
+// In case j=0 (default) the info of all waveforms will be listed.
+// In case j=-1 the info of all waveforms will be listed, but the header
+// information will be suppressed.
+
+ if (j<-1)
+ {
+ cout << " *AliSignal::ListWaveform* Invalid argument j = " << j << endl;
+ return;
+ }
+
+ if (j != -1)
+ {
+ const char* name=GetName();
+ const char* title=GetTitle();
+
+ cout << " *" << ClassName() << "::Data* Id :" << GetUniqueID();
+ if (strlen(name)) cout << " Name : " << name;
+ if (strlen(title)) cout << " Title : " << title;
+ cout << endl;
+ if (fDevice)
+ {
+ const char* devname=fDevice->GetName();
+ const char* devtitle=fDevice->GetTitle();
+ cout << " Owned by device : " << fDevice->ClassName();
+ if (strlen(devname)) cout << " Name : " << devname;
+ if (strlen(devtitle)) cout << " Title : " << devtitle;
+ cout << endl;
+ }
+ }
+
+ Int_t n=GetNwaveforms();
+ TObject* obj=0;
+
+ if (j<=0)
+ {
+ for (Int_t i=1; i<=n; i++)
+ {
+ obj=GetWaveform(i);
+ if (obj)
+ {
+ const char* wfname=obj->GetName();
+ const char* wftitle=obj->GetTitle();
+ cout << " Waveform " << i << " : " << obj->ClassName();
+ if (strlen(wfname)) cout << " Name : " << wfname;
+ if (strlen(wftitle)) cout << " Title : " << wftitle;
+ cout << endl;
+ }
+ }
+ }
+ else
+ {
+ if (j<=n)
+ {
+ obj=GetWaveform(j);
+ if (obj)
+ {
+ const char* wfnamej=obj->GetName();
+ const char* wftitlej=obj->GetTitle();
+ cout << " Waveform " << j << " : " << obj->ClassName();
+ if (strlen(wfnamej)) cout << " Name : " << wfnamej;
+ if (strlen(wftitlej)) cout << " Title : " << wftitlej;
+ cout << endl;
+ }
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
Int_t AliSignal::GetNvalues() const
{
// Provide the number of values for this signal.
///////////////////////////////////////////////////////////////////////////
Int_t AliSignal::GetNwaveforms() const
{
-// Provide the number specified waveforms for this signal.
- Int_t n=0;
- if (fWaveforms) n=fWaveforms->GetSize();
- return n;
+// Provide the number of specified waveforms for this signal.
+// Actually the return value is the highest index of the stored waveforms.
+// This allows an index dependent meaning of waveform info (e.g. waveforms
+// with various gain values).
+// So, when all waveforms are stored in consequetive positions (e.g. 1,2,3),
+// this memberfunction returns 3, being both the highest filled position
+// and the actual number of waveforms.
+// In case only waveforms are stored at positions 1,2,5,7 this memberfunction
+// returns a value 7 whereas only 4 actual waveforms are present.
+// This implies that when looping over the various waveform slots, one
+// always has to check whether the returned pointer value is non-zero
+// (which is a good practice anyhow).
+ Int_t n=-1;
+ if (fWaveforms) n=fWaveforms->GetLast();
+ return (n+1);
}
///////////////////////////////////////////////////////////////////////////
TH1F* AliSignal::GetWaveform(Int_t j) const
{
-// Provide pointer to the waveform histogram of the j-th slot.
+// Provide pointer to the j-th waveform histogram.
TH1F* waveform=0;
if (j <= GetNwaveforms()) waveform=(TH1F*)fWaveforms->At(j-1);
return waveform;
///////////////////////////////////////////////////////////////////////////
TH1F* AliSignal::GetWaveform(TString name) const
{
-// Provide pointer to the waveform histogram of the name-specified slot.
-//
-// This procedure involves a slot-index search based on the specified name
-// at each invokation. This may become slow in case many slots have been
-// defined and/or when this procedure is invoked many times.
-// In such cases it is preferable to use indexed addressing in the user code
-// either directly or via a few invokations of GetSlotIndex().
-
- Int_t j=GetSlotIndex(name);
- TH1F* waveform=0;
- if (j>0) waveform=GetWaveform(j);
- return waveform;
+// Provide pointer to the waveform histogram with the specified name.
+// In case no match is found, zero is returned.
+ Int_t n=GetNwaveforms();
+ TString str;
+ for (Int_t i=1; i<=n; i++)
+ {
+ TH1F* waveform=GetWaveform(i);
+ if (waveform)
+ {
+ str=waveform->GetName();
+ if (str == name) return waveform;
+ }
+ }
+ return 0; // No match found
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetWaveformIndex(TString name) const
+{
+// Provide index to the waveform histogram with the specified name.
+// In case no match is found, zero is returned.
+ Int_t n=GetNwaveforms();
+ TString str;
+ for (Int_t i=1; i<=n; i++)
+ {
+ TH1F* waveform=GetWaveform(i);
+ if (waveform)
+ {
+ str=waveform->GetName();
+ if (str == name) return i;
+ }
+ }
+ return 0; // No match found
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::SetWaveform(TH1F* waveform,Int_t j)
{
-// Set the 1D waveform histogram for the j-th slot.
+// Set the 1D waveform histogram for the j-th waveform.
//
// Notes :
-// The waveform of the first signal value is at j=1.
+// The first waveform position at j=1.
// j=1 is the default value.
//
// In case the value of the index j exceeds the maximum number of reserved
-// slots for the waveforms, the number of reserved slots for the waveforms
+// positions for the waveforms, the number of reserved positions for the waveforms
// is increased automatically.
//
// In case the histo pointer argument has the same value as the current waveform
// copy of the input histogram is created which becomes the current waveform
// histogram.
+ if (j<1) return;
+
if (!fWaveforms)
{
fWaveforms=new TObjArray(j);
}
}
///////////////////////////////////////////////////////////////////////////
-void AliSignal::SetWaveform(TH1F* waveform,TString name)
-{
-// Set the 1D waveform histogram corresponding for the name-specified slot.
-//
-// This procedure involves a slot-index search based on the specified name
-// at each invokation. This may become slow in case many slots have been
-// defined and/or when this procedure is invoked many times.
-// In such cases it is preferable to use indexed addressing in the user code
-// either directly or via a few invokations of GetSlotIndex().
-
- Int_t j=GetSlotIndex(name);
- if (j>0) SetWaveform(waveform,j);
-}
-///////////////////////////////////////////////////////////////////////////
void AliSignal::ResetWaveform(Int_t j)
{
-// Reset the waveform of the j-th (default j=1) slot.
+// Reset the histogram of the j-th (default j=1) waveform.
// This memberfunction invokes TH1F::Reset() for the corresponding waveform(s).
// To actually delete the histograms from memory, use DeleteWaveform().
-// Notes : The first signal value is at j=1.
+// Notes : The first position is at j=1.
// j=0 ==> All waveforms will be reset.
if (!fWaveforms) return;
///////////////////////////////////////////////////////////////////////////
void AliSignal::ResetWaveform(TString name)
{
-// Reset the waveform of the name-specified slot.
-//
-// This procedure involves a slot-index search based on the specified name
-// at each invokation. This may become slow in case many slots have been
-// defined and/or when this procedure is invoked many times.
-// In such cases it is preferable to use indexed addressing in the user code
-// either directly or via a few invokations of GetSlotIndex().
-
- Int_t j=GetSlotIndex(name);
+// Reset the waveform with the specified name.
+ Int_t j=GetWaveformIndex(name);
if (j>0) ResetWaveform(j);
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::DeleteWaveform(Int_t j)
{
-// Delete the waveform of the j-th (default j=1) slot.
-// Notes : The first signal value is at j=1.
+// Delete the histogram of the j-th (default j=1) waveform.
+// Notes : The first position is at j=1.
// j=0 ==> All waveforms will be deleted.
if (!fWaveforms) return;
///////////////////////////////////////////////////////////////////////////
void AliSignal::DeleteWaveform(TString name)
{
-// Delete the waveform of the name-specified slot.
-//
-// This procedure involves a slot-index search based on the specified name
-// at each invokation. This may become slow in case many slots have been
-// defined and/or when this procedure is invoked many times.
-// In such cases it is preferable to use indexed addressing in the user code
-// either directly or via a few invokations of GetSlotIndex().
-
- Int_t j=GetSlotIndex(name);
+// Delete the waveform with the specified name.
+ Int_t j=GetWaveformIndex(name);
if (j>0) DeleteWaveform(j);
}
///////////////////////////////////////////////////////////////////////////
return swap;
}
///////////////////////////////////////////////////////////////////////////
+void AliSignal::SetDevice(TObject* dev)
+{
+// Store the pointer to the device which owns this AliSignal object.
+// This memberfunction is meant for internal use in AliDevice.
+ fDevice=dev;
+}
+///////////////////////////////////////////////////////////////////////////
+AliDevice* AliSignal::GetDevice() const
+{
+// Provide the pointer to the device which owns this AliSignal object.
+ return (AliDevice*)fDevice;
+}
+///////////////////////////////////////////////////////////////////////////
TObject* AliSignal::Clone(const char* name) const
{
// Make a deep copy of the current object and provide the pointer to the copy.