//- Modified: NvE $Date$ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
+#include <cstdlib>
#include "AliSignal.h"
#include "AliTrack.h"
#include "Riostream.h"
// when entering values and/or errors.
fSignals=0;
fDsignals=0;
+ fSigflags=0;
fWaveforms=0;
fLinks=0;
fDevice=0;
delete fDsignals;
fDsignals=0;
}
+ if (fSigflags)
+ {
+ delete fSigflags;
+ fSigflags=0;
+ }
if (fWaveforms)
{
delete fWaveforms;
// Copy constructor
fSignals=0;
fDsignals=0;
+ fSigflags=0;
fWaveforms=0;
fLinks=0;
fTracks=0;
Int_t n=s.GetNvalues();
Double_t val;
+ Int_t lock;
for (Int_t i=1; i<=n; i++)
{
- val=s.GetSignal(i);
- SetSignal(val,i);
+ if (s.GetSignalFlag(i))
+ {
+ val=s.GetSignal(i);
+ lock=s.GetLockValue();
+ if (lock) Unlock();
+ SetSignal(val,i);
+ if (lock) Lock();
+ }
}
n=s.GetNerrors();
for (Int_t j=1; j<=n; j++)
{
- val=s.GetSignalError(j);
- SetSignalError(val,j);
+ if (s.GetErrorFlag(j))
+ {
+ val=s.GetSignalError(j);
+ lock=s.GetLockValue();
+ if (lock) Unlock();
+ SetSignalError(val,j);
+ if (lock) Lock();
+ }
}
n=s.GetNwaveforms();
{
// Reset various signal data according to user selection.
//
-// mode = 0 Reset all signal values and their errors to 0.
-// 1 Reset only signal values
-// 2 Reset only signal errors
+// mode = 0 Reset all signal values, their errors and all waveform histos.
+// 1 Reset only signal values and waveform histos.
+// 2 Reset only signal errors and waveform histos.
+// -1 Reset only signal values.
+// -2 Reset only signal errors.
//
// The default when invoking ResetSignals() corresponds to mode=0.
-//
-// Irrespective of the mode, the waveform histograms are reset.
- if (mode<0 || mode>2)
+ if (abs(mode)>2)
{
cout << " *AliSignal::ResetSignals* Invalid argument mode = " << mode << endl;
cout << " Default mode=0 will be used." << endl;
mode=0;
}
- if (fSignals && (mode==0 || mode==1))
+ Int_t sflag=0;
+ Int_t eflag=0;
+
+ if (fSignals && (abs(mode)==0 || abs(mode)==1))
{
- for (Int_t i=0; i<fSignals->GetSize(); i++)
+ for (Int_t i=1; i<=fSignals->GetSize(); i++)
{
- fSignals->AddAt(0,i);
+ fSignals->AddAt(0,i-1);
+ eflag=GetErrorFlag(i);
+ SetSigFlags(0,eflag,i);
}
}
- if (fDsignals && (mode==0 || mode==2))
+ if (fDsignals && (abs(mode)==0 || abs(mode)==2))
{
- for (Int_t j=0; j<fDsignals->GetSize(); j++)
+ for (Int_t j=1; j<=fDsignals->GetSize(); j++)
{
- fDsignals->AddAt(0,j);
+ fDsignals->AddAt(0,j-1);
+ sflag=GetSignalFlag(j);
+ SetSigFlags(sflag,0,j);
}
}
- ResetWaveform(0);
+ if (mode>=0) ResetWaveform(0);
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::DeleteSignals(Int_t mode)
{
// Delete storage arrays of various signal data according to user selection.
//
-// mode = 0 Delete arrays of both signal values and their errors.
-// 1 Delete only signal values array
-// 2 Delete only signal errors array
+// mode = 0 Delete arrays of signal values, their errors and all waveform histos.
+// 1 Delete only signal values array and waveform histos.
+// 2 Delete only signal errors array and waveform histos.
+// -1 Delete only signal values array.
+// -2 Delete only signal errors array.
//
// The default when invoking DeleteSignals() corresponds to mode=0.
-//
-// Irrespective of the mode, the waveform histograms are deleted.
- if (mode<0 || mode>2)
+ if (abs(mode)>2)
{
cout << " *AliSignal::DeleteSignals* Invalid argument mode = " << mode << endl;
cout << " Default mode=0 will be used." << endl;
mode=0;
}
- if (fSignals && (mode==0 || mode==1))
+ if (fSignals && (abs(mode)==0 || abs(mode)==1))
{
delete fSignals;
fSignals=0;
}
- if (fDsignals && (mode==0 || mode==2))
+ if (fDsignals && (abs(mode)==0 || abs(mode)==2))
{
delete fDsignals;
fDsignals=0;
}
- DeleteWaveform(0);
+ Int_t sflag=0;
+ Int_t eflag=0;
+
+ if (mode==0)
+ {
+ delete fSigflags;
+ fSigflags=0;
+ }
+ else if (abs(mode)==1)
+ {
+ for (Int_t i=1; i<=fSigflags->GetSize(); i++)
+ {
+ eflag=GetErrorFlag(i);
+ SetSigFlags(0,eflag,i);
+ }
+ }
+ else if (abs(mode)==2)
+ {
+ for (Int_t j=1; j<=fSigflags->GetSize(); j++)
+ {
+ sflag=GetSignalFlag(j);
+ SetSigFlags(sflag,0,j);
+ }
+ }
+
+ if (mode>=0) DeleteWaveform(0);
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::SetSignal(Double_t sig,Int_t j)
{
// Store signal value for the j-th (default j=1) slot.
-// Note : The first signal slot is at j=1.
+// Notes :
+// -------
+// 1) The first signal slot is at j=1.
+// 2) In case the 'lock' flag was set for the specified slot, the new
+// signal value will not be stored.
+// One has to unlock the specified slot first in case one really wants
+// to overwite the signal value.
// In case the value of the index j exceeds the maximum number of reserved
// slots for signal values, the number of reserved slots for the
// signal values is increased automatically.
+ if (GetLockValue(j)) return;
+
if (!fSignals)
{
fSignals=new TArrayF(j);
- ResetSignals(1);
+ ResetSignals(-1);
}
Int_t size=fSignals->GetSize();
}
fSignals->AddAt(float(sig),j-1);
+
+ Int_t eflag=GetErrorFlag(j);
+ SetSigFlags(1,eflag,j);
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::SetSignal(Double_t sig,TString name)
{
// Store signal value for the name-specified slot.
//
+// Note :
+// ------
+// In case the 'lock' flag was set for the specified slot, the new
+// signal value will not be stored.
+// One has to unlock the specified slot first in case one really wants
+// to overwite the signal value.
+//
// 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.
// either directly or via a few invokations of GetSlotIndex().
Int_t j=GetSlotIndex(name);
- if (j>0) SetSignal(sig,j);
+ if (j>0)
+ {
+ if (!GetLockValue(j)) SetSignal(sig,j);
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::AddSignal(Double_t sig,Int_t j)
{
// Add value to the signal of the j-th (default j=1) slot.
-// Note : The first signal slot is at j=1.
+// Notes :
+// -------
+// 1) The first signal slot is at j=1.
+// 2) In case the 'lock' flag was set for the specified slot, the new
+// signal value will not be stored.
+// One has to unlock the specified slot first in case one really wants
+// to overwite the signal value.
// In case the value of the index j exceeds the maximum number of reserved
// slots for signal values, the number of reserved slots for the
// signal values is increased automatically.
+ if (GetLockValue(j)) return;
+
if (!fSignals)
{
fSignals=new TArrayF(j);
Float_t sum=(fSignals->At(j-1))+sig;
fSignals->AddAt(sum,j-1);
+
+ Int_t eflag=GetErrorFlag(j);
+ SetSigFlags(1,eflag,j);
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::AddSignal(Double_t sig,TString name)
{
// Add value to the signal of the name-specified slot.
//
+// Note :
+// ------
+// In case the 'lock' flag was set for the specified slot, the new
+// signal value will not be stored.
+// One has to unlock the specified slot first in case one really wants
+// to overwite the signal value.
+//
// 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.
// either directly or via a few invokations of GetSlotIndex().
Int_t j=GetSlotIndex(name);
- if (j>0) AddSignal(sig,j);
+ if (j>0)
+ {
+ if (!GetLockValue(j)) AddSignal(sig,j);
+ }
}
///////////////////////////////////////////////////////////////////////////
Float_t AliSignal::GetSignal(Int_t j,Int_t mode) const
void AliSignal::SetSignalError(Double_t dsig,Int_t j)
{
// Store error on the signal for the j-th (default j=1) slot.
-// Note : The first signal slot is at j=1.
+// Notes :
+// -------
+// 1) The first signal slot is at j=1.
+// 2) In case the 'lock' flag was set for the specified slot, the new
+// signal error value will not be stored.
+// One has to unlock the specified slot first in case one really wants
+// to overwite the signal error value.
// In case the value of the index j exceeds the maximum number of reserved
// slots for signal error values, the number of reserved slots for the
// signal errors is increased automatically.
+ if (GetLockValue(j)) return;
+
if (!fDsignals)
{
fDsignals=new TArrayF(j);
- ResetSignals(2);
+ ResetSignals(-2);
}
Int_t size=fDsignals->GetSize();
}
fDsignals->AddAt(float(dsig),j-1);
+
+ Int_t sflag=GetSignalFlag(j);
+ SetSigFlags(sflag,1,j);
}
///////////////////////////////////////////////////////////////////////////
void AliSignal::SetSignalError(Double_t dsig,TString name)
{
// Store error on the signal for the name-specified slot.
//
+// Note :
+// ------
+// In case the 'lock' flag was set for the specified slot, the new
+// signal error value will not be stored.
+// One has to unlock the specified slot first in case one really wants
+// to overwite the signal error value.
+//
// 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.
// either directly or via a few invokations of GetSlotIndex().
Int_t j=GetSlotIndex(name);
- if (j>0) SetSignalError(dsig,j);
+ if (j>0)
+ {
+ if (!GetLockValue(j)) SetSignalError(dsig,j);
+ }
}
///////////////////////////////////////////////////////////////////////////
Float_t AliSignal::GetSignalError(Int_t j) const
}
}
- Int_t nvalues=GetNvalues();
- Int_t nerrors=GetNerrors();
+ Int_t n=GetNslots();
Int_t nlinkslots=0;
if (GetNlinks()) nlinkslots=fLinks->GetMaxColumn();
- Int_t ncalibs=GetNcalflags();
- Int_t ncalfuncs=GetNcalfuncs();
- Int_t ndecalfuncs=GetNdecalfuncs();
-
- Int_t n=nvalues;
- if (nerrors>n) n=nerrors;
if (nlinkslots>n) n=nlinkslots;
- if (InheritsFrom("AliDevice"))
- {
- if (ncalibs>n) n=ncalibs;
- if (ncalfuncs>n) n=ncalfuncs;
- if (ndecalfuncs>n) n=ndecalfuncs;
- }
TObject* obj=0;
Int_t nrefs=0;
{
for (Int_t i=1; i<=n; i++)
{
- cout << " Slot : " << i;
- if (i<=nvalues) cout << " Signal value : " << GetSignal(i);
- if (i<=nerrors) cout << " error : " << GetSignalError(i);
- AliAttrib::List(i);
- cout << endl;
obj=0;
nrefs=GetIndices(obj,i,posarr);
- for (Int_t k=0; k<nrefs; k++)
+
+ if (GetSignalFlag(i) || GetErrorFlag(i) || GetCalFunction(i) || GetDecalFunction(i) || GetCalWord(i) || nrefs)
{
- pos=posarr.At(k);
- obj=GetLink(i,pos);
- if (obj)
+ cout << " Slot : " << i;
+ if (GetSignalFlag(i)) cout << " Signal value : " << GetSignal(i);
+ if (GetErrorFlag(i)) cout << " error : " << GetSignalError(i);
+ AliAttrib::List(i);
+ cout << endl;
+
+ for (Int_t k=0; k<nrefs; k++)
{
- cout << " Link at position " << pos << " to : " << obj->ClassName();
- if (obj->InheritsFrom("TNamed"))
+ pos=posarr.At(k);
+ obj=GetLink(i,pos);
+ if (obj)
{
- const char* lname=obj->GetName();
- const char* ltitle=obj->GetTitle();
- if (strlen(lname)) cout << " Name : " << lname;
- if (strlen(ltitle)) cout << " Title : " << ltitle;
+ cout << " Link at position " << pos << " to : " << obj->ClassName();
+ if (obj->InheritsFrom("TNamed"))
+ {
+ const char* lname=obj->GetName();
+ const char* ltitle=obj->GetTitle();
+ if (strlen(lname)) cout << " Name : " << lname;
+ if (strlen(ltitle)) cout << " Title : " << ltitle;
+ }
+ cout << endl;
}
- cout << endl;
}
}
}
{
if (j<=n)
{
- cout << " Slot : " << j;
- if (j<=nvalues) cout << " Signal value : " << GetSignal(j);
- if (j<=nerrors) cout << " error : " << GetSignalError(j);
- AliAttrib::List(j);
- cout << endl;
obj=0;
nrefs=GetIndices(obj,j,posarr);
- for (Int_t kj=0; kj<nrefs; kj++)
+
+ if (GetSignalFlag(j) || GetErrorFlag(j) || GetCalFunction(j) || GetDecalFunction(j) || GetCalWord(j) || nrefs)
{
- pos=posarr.At(kj);
- obj=GetLink(j,pos);
- if (obj)
+ cout << " Slot : " << j;
+ if (GetSignalFlag(j)) cout << " Signal value : " << GetSignal(j);
+ if (GetErrorFlag(j)) cout << " error : " << GetSignalError(j);
+ AliAttrib::List(j);
+ cout << endl;
+
+ for (Int_t kj=0; kj<nrefs; kj++)
{
- cout << " Link at position " << pos << " to : " << obj->ClassName();
- if (obj->InheritsFrom("TNamed"))
+ pos=posarr.At(kj);
+ obj=GetLink(j,pos);
+ if (obj)
{
- const char* lnamej=obj->GetName();
- const char* ltitlej=obj->GetTitle();
- if (strlen(lnamej)) cout << " Name : " << lnamej;
- if (strlen(ltitlej)) cout << " Title : " << ltitlej;
+ cout << " Link at position " << pos << " to : " << obj->ClassName();
+ if (obj->InheritsFrom("TNamed"))
+ {
+ const char* lnamej=obj->GetName();
+ const char* ltitlej=obj->GetTitle();
+ if (strlen(lnamej)) cout << " Name : " << lnamej;
+ if (strlen(ltitlej)) cout << " Title : " << ltitlej;
+ }
+ cout << endl;
}
- cout << endl;
}
}
}
Int_t AliSignal::GetNvalues() const
{
// Provide the number of values for this signal.
+
+ if (!fSignals) return 0;
+
Int_t n=0;
- if (fSignals) n=fSignals->GetSize();
+ for (Int_t i=1; i<=fSigflags->GetSize(); i++)
+ {
+ if (GetSignalFlag(i)) n=i;
+ }
+
return n;
}
///////////////////////////////////////////////////////////////////////////
Int_t AliSignal::GetNerrors() const
{
// Provide the number specified errors on the values for this signal.
+
+ if (!fDsignals) return 0;
+
Int_t n=0;
- if (fDsignals) n=fDsignals->GetSize();
+ for (Int_t i=1; i<=fSigflags->GetSize(); i++)
+ {
+ if (GetErrorFlag(i)) n=i;
+ }
+
+ return n;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliSignal::SetSigFlags(Int_t is,Int_t ie,Int_t j)
+{
+// Store signal and/or error value flags of the j-th (default j=1) slot.
+// Note : The first slot is at j=1.
+// In case the value of the index j exceeds the maximum number of reserved
+// slots for the flags, the number of reserved slots for the flags is
+// increased automatically.
+// The value stored is : 10*signalflag + errorflag.
+
+ if (j<1)
+ {
+ cout << " *AliSignal::SetSigFlags* Invalid argument j = " << j << endl;
+ return;
+ }
+
+ if (!fSigflags)
+ {
+ fSigflags=new TArrayI(j);
+ }
+
+ Int_t size=fSigflags->GetSize();
+
+ if (j>size)
+ {
+ fSigflags->Set(j);
+ }
+
+ Int_t word=10*is+ie;
+
+ fSigflags->AddAt(word,j-1);
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetSignalFlag(Int_t j) const
+{
+// Provide signal value flag of the j-th (default j=1) slot.
+//
+// flag = 1 : Signal value was set
+// 0 : Signal value was not set
+//
+// Note : The first attribute slot is at j=1.
+// In case j is invalid, 0 is returned.
+
+ if (j<1)
+ {
+ cout << " *AliSignal::GetSignalFlag* Invalid argument j = " << j << endl;
+ return 0;
+ }
+ Int_t flag=0;
+ if (fSigflags)
+ {
+ if (j>0 && j<=(fSigflags->GetSize()))
+ {
+ Int_t word=fSigflags->At(j-1);
+ flag=word/10;
+ }
+ }
+ return flag;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetSignalFlag(TString name) const
+{
+// Provide signal value flag of the name-specified slot.
+//
+// flag = 1 : Signal value was set
+// 0 : Signal value was not set
+//
+//
+// 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);
+ Int_t flag=0;
+ if (j>0) flag=GetSignalFlag(j);
+ return flag;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetErrorFlag(Int_t j) const
+{
+// Provide error value flag of the j-th (default j=1) slot.
+//
+// flag = 1 : Error value was set
+// 0 : Error value was not set
+//
+// Note : The first attribute slot is at j=1.
+// In case j is invalid, 0 is returned.
+
+ if (j<1)
+ {
+ cout << " *AliSignal::GetErrorFlag* Invalid argument j = " << j << endl;
+ return 0;
+ }
+ Int_t flag=0;
+ if (fSigflags)
+ {
+ if (j>0 && j<=(fSigflags->GetSize()))
+ {
+ Int_t word=fSigflags->At(j-1);
+ flag=word%10;
+ }
+ }
+ return flag;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetErrorFlag(TString name) const
+{
+// Provide error value flag of the name-specified slot.
+//
+// flag = 1 : Error value was set
+// 0 : Error value was not set
+//
+//
+// 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);
+ Int_t flag=0;
+ if (j>0) flag=GetErrorFlag(j);
+ return flag;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetNslots() const
+{
+// Provide the number of existing slots.
+
+ Int_t n=AliAttrib::GetNslots();
+
+ if (!fSigflags) return n;
+
+ Int_t nflags=0;
+ for (Int_t i=0; i<fSigflags->GetSize(); i++)
+ {
+ if (fSigflags->At(i)) nflags=i+1;
+ }
+
+ if (n<nflags) n=nflags;
+
return n;
}
///////////////////////////////////////////////////////////////////////////