]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliAttrib.cxx
07-oct-2004 NvE Docs of AliAttrib and AliSignal updated for new data access via slotn...
[u/mrichter/AliRoot.git] / RALICE / AliAttrib.cxx
index 685667663e441c05497ee60433b97ad5b4689808..00a34e2ad037431baface33a2ecaa7bd75162475 100644 (file)
 // Example :
 // ---------
 // AliAttrib a;
-// a.SetGain(250.7);
 // a.SetSlotName("PMT amplitude in Volt");
-// a.SetGain(1340,3);
+// a.SetGain(250.7);
+// a.SetSlotName("Time of flight in ns",2);
+// a.SetOffset(-22.5,2);
 // a.SetSlotName("PMT amplitude in ADC",3);
+// a.SetGain(1340,3);
+// a.SetSlotName("TDC",4);
+// a.SetOffset(10.75,"TDC");
 // a.SetEdgeOn(3);
-// a.SetOffset(-22.5,2);
-// a.SetSlotName("Time of flight in ns",2);
 // a.SetDead(1);
-// a.Data();
+// a.List();
 //
 //--- Author: Nick van Eijndhoven 18-sep-2003 Utrecht University
 //- Modified: NvE $Date$ Utrecht University
@@ -82,7 +84,7 @@ AliAttrib::~AliAttrib()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliAttrib::AliAttrib(AliAttrib& a)
+AliAttrib::AliAttrib(const AliAttrib& a)
 {
 // Copy constructor
  fGains=0;
@@ -123,7 +125,7 @@ AliAttrib::AliAttrib(AliAttrib& a)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetNgains()
+Int_t AliAttrib::GetNgains() const
 {
 // Provide the number of specified gains for this attribute.
  Int_t n=0;
@@ -131,7 +133,7 @@ Int_t AliAttrib::GetNgains()
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetNoffsets()
+Int_t AliAttrib::GetNoffsets() const
 {
 // Provide the number of specified offsets for this attribute.
  Int_t n=0;
@@ -139,7 +141,7 @@ Int_t AliAttrib::GetNoffsets()
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetNcalflags()
+Int_t AliAttrib::GetNcalflags() const
 {
 // Provide the number of specified calib. flags for this attribute.
  Int_t n=0;
@@ -147,7 +149,7 @@ Int_t AliAttrib::GetNcalflags()
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetNnames()
+Int_t AliAttrib::GetNnames() const
 {
 // Provide the maximum number of specified names for this attribute.
  Int_t n=0;
@@ -188,6 +190,20 @@ void AliAttrib::SetGain(Double_t gain,Int_t j)
  SetCalFlags(1,oflag,j);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetGain(Double_t gain,TString name)
+{
+// Store gain value of the name-specified attribute 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) SetGain(gain,j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetOffset(Double_t off,Int_t j)
 {
 // Store offset value of the j-th (default j=1) attribute slot.
@@ -221,6 +237,20 @@ void AliAttrib::SetOffset(Double_t off,Int_t j)
  SetCalFlags(gflag,1,j);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetOffset(Double_t off,TString name)
+{
+// Store offset value of the name-specified attribute 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) SetOffset(off,j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
 {
 // Store calibration flags of the j-th (default j=1) attribute slot.
@@ -256,7 +286,7 @@ void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
  fCalflags->AddAt(word,j-1);
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetGainFlag(Int_t j)
+Int_t AliAttrib::GetGainFlag(Int_t j) const
 {
 // Provide gain flag of the j-th (default j=1) attribute slot.
 //
@@ -284,7 +314,27 @@ Int_t AliAttrib::GetGainFlag(Int_t j)
  return gflag;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetOffsetFlag(Int_t j)
+Int_t AliAttrib::GetGainFlag(TString name) const
+{
+// Provide gain flag of the name-specified attribute slot.
+//
+// flag = 1 : Gain was set
+//        0 : Gain 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=GetGainFlag(j);
+ return flag;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetOffsetFlag(Int_t j) const
 {
 // Provide offset flag of the j-th (default j=1) attribute slot.
 //
@@ -312,7 +362,27 @@ Int_t AliAttrib::GetOffsetFlag(Int_t j)
  return oflag;
 }
 ///////////////////////////////////////////////////////////////////////////
-Float_t AliAttrib::GetGain(Int_t j)
+Int_t AliAttrib::GetOffsetFlag(TString name) const
+{
+// Provide ofset flag of the name-specified attribute slot.
+//
+// flag = 1 : Offset was set
+//        0 : Offset 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=GetOffsetFlag(j);
+ return flag;
+}
+///////////////////////////////////////////////////////////////////////////
+Float_t AliAttrib::GetGain(Int_t j) const
 {
 // Provide gain value of the j-th (default j=1) attribute slot.
 // The first attribute slot is at j=1.
@@ -336,7 +406,23 @@ Float_t AliAttrib::GetGain(Int_t j)
  return gain;
 }
 ///////////////////////////////////////////////////////////////////////////
-Float_t AliAttrib::GetOffset(Int_t j)
+Float_t AliAttrib::GetGain(TString name) const
+{
+// Provide gain value of the name-specified attribute 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);
+ Float_t gain=0;
+ if (j>0) gain=GetGain(j);
+ return gain;
+}
+///////////////////////////////////////////////////////////////////////////
+Float_t AliAttrib::GetOffset(Int_t j) const
 {
 // Provide offset value of the j-th (default j=1) attribute slot.
 // The first attribute slot at j=1.
@@ -360,6 +446,22 @@ Float_t AliAttrib::GetOffset(Int_t j)
  return offset;
 }
 ///////////////////////////////////////////////////////////////////////////
+Float_t AliAttrib::GetOffset(TString name) const
+{
+// Provide offset value of the name-specified attribute 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);
+ Float_t offset=0;
+ if (j>0) offset=GetOffset(j);
+ return offset;
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::ResetGain(Int_t j)
 {
 // Reset the gain value of the j-th (default j=1) attribute slot.
@@ -395,6 +497,20 @@ void AliAttrib::ResetGain(Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::ResetGain(TString name)
+{
+// Reset the gain value of the name-specified attribute 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) ResetGain(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::ResetOffset(Int_t j)
 {
 // Reset the offset value of the j-th (default j=1) attribute slot.
@@ -430,6 +546,20 @@ void AliAttrib::ResetOffset(Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::ResetOffset(TString name)
+{
+// Reset the offset value of the name-specified attribute 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) ResetOffset(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::DeleteCalibrations(Int_t mode)
 {
 // User selected delete of all gains and/or offsets.
@@ -531,6 +661,20 @@ void AliAttrib::SetDead(Int_t j)
  fCalflags->AddAt(word,j-1);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetDead(TString name)
+{
+// Set the dead flag to 1 for the name-specified attribute 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) SetDead(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetAlive(Int_t j)
 {
 // Set the dead flag to 0 for the j-th (default j=1) attribute slot.
@@ -557,6 +701,20 @@ void AliAttrib::SetAlive(Int_t j)
  fCalflags->AddAt(word,j-1);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetAlive(TString name)
+{
+// Set the dead flag to 0 for the name-specified attribute 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) SetAlive(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetEdgeOn(Int_t j)
 {
 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
@@ -575,6 +733,20 @@ void AliAttrib::SetEdgeOn(Int_t j)
  SetEdgeValue(1,j);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetEdgeOn(TString name)
+{
+// Set the edge value to 1 for the name-specified attribute 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) SetEdgeOn(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetEdgeOff(Int_t j)
 {
 // Set the edge value to 0 for the j-th (default j=1) attribute slot.
@@ -594,6 +766,20 @@ void AliAttrib::SetEdgeOff(Int_t j)
  SetEdgeValue(0,j);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetEdgeOff(TString name)
+{
+// Set the edge value to 0 for the name-specified attribute 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) SetEdgeOff(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
 {
 // Set the edge value to "val" for the j-th (default j=1) attribute slot.
@@ -631,6 +817,20 @@ void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
  fCalflags->AddAt(word,j-1);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::SetEdgeValue(Int_t val,TString name)
+{
+// Set the edge value to "val" for the name-specified attribute 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) SetEdgeValue(val,j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::IncreaseEdgeValue(Int_t j)
 {
 // Increase the edge value by 1 for the j-th (default j=1) attribute slot.
@@ -650,6 +850,20 @@ void AliAttrib::IncreaseEdgeValue(Int_t j)
  SetEdgeValue(edge+1,j);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::IncreaseEdgeValue(TString name)
+{
+// Increase the edge value by 1 for the name-specified attribute 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) IncreaseEdgeValue(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::DecreaseEdgeValue(Int_t j)
 {
 // Decrease the edge value by 1 for the j-th (default j=1) attribute slot.
@@ -669,7 +883,21 @@ void AliAttrib::DecreaseEdgeValue(Int_t j)
  SetEdgeValue(edge-1,j);
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetEdgeValue(Int_t j)
+void AliAttrib::DecreaseEdgeValue(TString name)
+{
+// Decrease the edge value by 1 for the name-specified attribute 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) DecreaseEdgeValue(j);
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetEdgeValue(Int_t j) const
 {
 // Provide edge value of the j-th (default j=1) attribute slot.
 // Note : The first attribute slot is at j=1.
@@ -693,7 +921,23 @@ Int_t AliAttrib::GetEdgeValue(Int_t j)
  return edge;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetDeadValue(Int_t j)
+Int_t AliAttrib::GetEdgeValue(TString name) const
+{
+// Provide edge value of the name-specified attribute 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);
+ Int_t val=0;
+ if (j>0) val=GetEdgeValue(j);
+ return val;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetDeadValue(Int_t j) const
 {
 // Provide dead value of the j-th (default j=1) attribute slot.
 // Note : The first attribute slot is at j=1.
@@ -718,15 +962,20 @@ Int_t AliAttrib::GetDeadValue(Int_t j)
  return dead;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliAttrib* AliAttrib::MakeCopy(AliAttrib& a)
+Int_t AliAttrib::GetDeadValue(TString name) const
 {
-// Make a deep copy of the input object and provide the pointer to the copy.
-// This memberfunction enables automatic creation of new objects of the
-// correct type depending on the argument type, a feature which may be very useful
-// for containers when adding objects in case the container owns the objects.
-
- AliAttrib* att=new AliAttrib(a);
- return att;
+// Provide dead value of the name-specified attribute 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);
+ Int_t val=0;
+ if (j>0) val=GetDeadValue(j);
+ return val;
 }
 ///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetSlotName(TString s,Int_t j)
@@ -760,7 +1009,7 @@ void AliAttrib::SetSlotName(TString s,Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-TString AliAttrib::GetSlotName(Int_t j)
+TString AliAttrib::GetSlotName(Int_t j) const
 {
 // Provide the user defined name for the j-th (default j=1) slot. 
 // Note : The first attribute slot is at j=1.
@@ -783,7 +1032,7 @@ TString AliAttrib::GetSlotName(Int_t j)
  return s;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliAttrib::GetSlotIndex(TString name)
+Int_t AliAttrib::GetSlotIndex(TString name) const
 {
 // Provide the slot index for the matching name.
 // If no matching name is found, 0 is returned.
@@ -798,14 +1047,14 @@ Int_t AliAttrib::GetSlotIndex(TString name)
   for (Int_t i=0; i<size; i++)
   {
    TObjString* so=(TObjString*)fNames->At(i);
-   s=so->GetString();
+   if (so) s=so->GetString();
    if (s==name) index=i+1;
   }
  }
  return index;
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliAttrib::Data(Int_t j)
+void AliAttrib::List(Int_t j) const
 {
 // Provide attribute information for the j-th slot.
 // The first slot is at j=1.
@@ -853,6 +1102,20 @@ void AliAttrib::Data(Int_t j)
  }
 } 
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::List(TString name) const
+{
+// Provide attribute information 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) List(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::Load(AliAttrib& a,Int_t j)
 {
 // Load attributes of the j-th slot of the input AliAttrib into this AliAttrib object.
@@ -969,3 +1232,18 @@ void AliAttrib::Load(AliAttrib& a,Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::Load(AliAttrib& a,TString name)
+{
+// Load attributes of the name-specified slot of the input AliAttrib into
+// this AliAttrib object.
+//
+// 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) Load(a,j);
+}
+///////////////////////////////////////////////////////////////////////////