]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliAttrib.cxx
Removed classes not included in compilation
[u/mrichter/AliRoot.git] / RALICE / AliAttrib.cxx
index dd553320a7d392648691237c0df1cc6de7a54844..1a8f9b082d58c8ed912f0a8fe275105108209c8c 100644 (file)
@@ -127,6 +127,7 @@ AliAttrib::AliAttrib(const AliAttrib& a)
  for (Int_t ic=1; ic<=n; ic++)
  {
   SetEdgeValue(a.GetEdgeValue(ic),ic);
+  if (a.GetLockValue(ic)) Lock(ic);
   if (a.GetDeadValue(ic)) SetDead(ic);
  }
 
@@ -156,32 +157,60 @@ AliAttrib::AliAttrib(const AliAttrib& a)
 Int_t AliAttrib::GetNgains() const
 {
 // Provide the number of specified gains for this attribute.
+
+ if (!fGains) return 0;
+
  Int_t n=0;
- if (fGains) n=fGains->GetSize();
+ for (Int_t i=1; i<=fGains->GetSize(); i++)
+ {
+  if (GetGainFlag(i)) n=i;
+ }
+
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
 Int_t AliAttrib::GetNoffsets() const
 {
 // Provide the number of specified offsets for this attribute.
+
+ if (!fOffsets) return 0;
+
  Int_t n=0;
- if (fOffsets) n=fOffsets->GetSize();
+ for (Int_t i=1; i<=fOffsets->GetSize(); i++)
+ {
+  if (GetOffsetFlag(i)) n=i;
+ }
+
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
 Int_t AliAttrib::GetNcalflags() const
 {
 // Provide the number of specified calib. flags for this attribute.
+
+ if (!fCalflags) return 0;
+
  Int_t n=0;
- if (fCalflags) n=fCalflags->GetSize();
+ for (Int_t i=1; i<=fCalflags->GetSize(); i++)
+ {
+  if (fCalflags->At(i-1)) n=i;
+ }
+
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
 Int_t AliAttrib::GetNnames() const
 {
 // Provide the maximum number of specified names for this attribute.
+
+ if (!fNames) return 0;
+
  Int_t n=0;
- if (fNames) n=fNames->GetSize();
+ for (Int_t i=1; i<=fNames->GetSize(); i++)
+ {
+  if (fNames->At(i-1)) n=i;
+ }
+
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -286,7 +315,7 @@ void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
 // In case the value of the index j exceeds the maximum number of reserved
 // slots for the calib. flags, the number of reserved slots for the calib.
 // flags is increased automatically.
-// The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge +1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -307,9 +336,10 @@ void AliAttrib::SetCalFlags(Int_t gainflag,Int_t offsetflag,Int_t j)
  }
 
  Int_t edge=GetEdgeValue(j);
+ Int_t lock=GetLockValue(j);
  Int_t dead=GetDeadValue(j);
 
- Int_t word=1000*edge+100*dead+10*gainflag+offsetflag;
+ Int_t word=10000*edge+1000*lock+100*dead+10*gainflag+offsetflag;
  
  fCalflags->AddAt(word,j-1);
 }
@@ -410,6 +440,45 @@ Int_t AliAttrib::GetOffsetFlag(TString name) const
  return flag;
 }
 ///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetCalWord(Int_t j) const
+{
+// Provide calib. word of the j-th (default j=1) attribute slot.
+// The word value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
+//
+// Note : The first attribute slot is at j=1.
+// In case j is invalid, 0 is returned.
+
+ if (j<1) 
+ {
+  cout << " *AliAttrib::GetCalWord* Invalid argument j = " << j << endl;
+  return 0;
+ }
+
+ Int_t word=0;
+ if (fCalflags)
+ {
+  if (j>0 && j<=(fCalflags->GetSize())) word=fCalflags->At(j-1);
+ }
+ return word;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetCalWord(TString name) const
+{
+// Provide calib. word of the name-specified attribute slot.
+// The word value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
+//
+// 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 word=0;
+ if (j>0) word=GetCalWord(j);
+ return word;
+}
+///////////////////////////////////////////////////////////////////////////
 Float_t AliAttrib::GetGain(Int_t j) const
 {
 // Provide gain value of the j-th (default j=1) attribute slot.
@@ -691,7 +760,7 @@ void AliAttrib::SetDead(Int_t j)
 // 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 : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -714,9 +783,10 @@ void AliAttrib::SetDead(Int_t j)
  Int_t dead=1;
  Int_t oflag=GetOffsetFlag(j);
  Int_t gflag=GetGainFlag(j);
+ Int_t lock=GetLockValue(j);
  Int_t edge=GetEdgeValue(j);
 
- Int_t word=1000*edge+100*dead+10*gflag+oflag;
+ Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
  
  fCalflags->AddAt(word,j-1);
 }
@@ -741,7 +811,7 @@ void AliAttrib::SetAlive(Int_t j)
 // Note : The first attribute slot is at j=1.
 // In case the value of the index j exceeds the maximum number of reserved
 // slots for the flags, no action is taken since by default the dead flag is 0.
-// The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -754,9 +824,10 @@ void AliAttrib::SetAlive(Int_t j)
  Int_t dead=0;
  Int_t oflag=GetOffsetFlag(j);
  Int_t gflag=GetGainFlag(j);
+ Int_t lock=GetLockValue(j);
  Int_t edge=GetEdgeValue(j);
 
- Int_t word=1000*edge+100*dead+10*gflag+oflag;
+ Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
  
  fCalflags->AddAt(word,j-1);
 }
@@ -775,6 +846,99 @@ void AliAttrib::SetAlive(TString name)
  if (j>0) SetAlive(j);
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliAttrib::Lock(Int_t j)
+{
+// Set the lock flag to 1 for the j-th (default j=1) attribute slot.
+// Note : The first attribute 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 : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
+
+ if (j<1) 
+ {
+  cout << " *AliAttrib::Lock* Invalid argument j = " << j << endl;
+  return;
+ }
+
+ if (!fCalflags)
+ {
+  fCalflags=new TArrayI(j);
+ }
+
+ Int_t size=fCalflags->GetSize();
+
+ if (j>size)
+ {
+  fCalflags->Set(j);
+ }
+
+ Int_t lock=1;
+ Int_t dead=GetDeadValue(j);
+ Int_t oflag=GetOffsetFlag(j);
+ Int_t gflag=GetGainFlag(j);
+ Int_t edge=GetEdgeValue(j);
+
+ Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
+ fCalflags->AddAt(word,j-1);
+}
+///////////////////////////////////////////////////////////////////////////
+void AliAttrib::Lock(TString name)
+{
+// Set the lock 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) Lock(j);
+}
+///////////////////////////////////////////////////////////////////////////
+void AliAttrib::Unlock(Int_t j)
+{
+// Set the lock flag to 0 for the j-th (default j=1) attribute slot.
+// Note : The first attribute slot is at j=1.
+// In case the value of the index j exceeds the maximum number of reserved
+// slots for the flags, no action is taken since by default the dead flag is 0.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
+
+ if (j<1) 
+ {
+  cout << " *AliAttrib::Unlock* Invalid argument j = " << j << endl;
+  return;
+ }
+
+ if (!fCalflags || j>fCalflags->GetSize()) return;
+
+ Int_t lock=0;
+ Int_t dead=GetDeadValue();
+ Int_t oflag=GetOffsetFlag(j);
+ Int_t gflag=GetGainFlag(j);
+ Int_t edge=GetEdgeValue(j);
+
+ Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
+ fCalflags->AddAt(word,j-1);
+}
+///////////////////////////////////////////////////////////////////////////
+void AliAttrib::Unlock(TString name)
+{
+// Set the lock 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) Unlock(j);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetEdgeOn(Int_t j)
 {
 // Set the edge value to 1 for the j-th (default j=1) attribute slot.
@@ -782,7 +946,7 @@ void AliAttrib::SetEdgeOn(Int_t j)
 // 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 : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -813,7 +977,7 @@ void AliAttrib::SetEdgeOff(Int_t j)
 // Note : The first attribute slot is at j=1.
 // In case the value of the index j exceeds the maximum number of reserved
 // slots for the flags, no action is taken since by default the edge flag is 0.
-// The value stored is : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -847,7 +1011,7 @@ void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
 // 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 : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -868,11 +1032,12 @@ void AliAttrib::SetEdgeValue(Int_t val,Int_t j)
  }
 
  Int_t edge=val;
+ Int_t lock=GetLockValue(j);
  Int_t dead=GetDeadValue(j);
  Int_t gflag=GetGainFlag(j);
  Int_t oflag=GetOffsetFlag(j);
 
- Int_t word=1000*edge+100*dead+10*gflag+oflag;
+ Int_t word=10000*edge+1000*lock+100*dead+10*gflag+oflag;
  
  fCalflags->AddAt(word,j-1);
 }
@@ -898,7 +1063,7 @@ void AliAttrib::IncreaseEdgeValue(Int_t j)
 // 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 : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -931,7 +1096,7 @@ void AliAttrib::DecreaseEdgeValue(Int_t j)
 // 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 : 1000*edge + 100*dead + 10*gainflag + offsetflag.
+// The value stored is : 10000*edge + 1000*lock + 100*dead + 10*gainflag + offsetflag.
 
  if (j<1) 
  {
@@ -975,7 +1140,7 @@ Int_t AliAttrib::GetEdgeValue(Int_t j) const
   if (j>0 && j<=(fCalflags->GetSize()))
   {
    Int_t word=fCalflags->At(j-1);
-   edge=word/1000;
+   edge=word/10000;
   }
  }
  return edge;
@@ -1038,10 +1203,80 @@ Int_t AliAttrib::GetDeadValue(TString name) const
  return val;
 }
 ///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetLockValue(Int_t j) const
+{
+// Provide lock value of the j-th (default j=1) attribute slot.
+// Note : The first attribute slot is at j=1.
+// In case j is invalid, 0 is returned.
+
+ if (j<1) 
+ {
+  cout << " *AliAttrib::GetLockValue* Invalid argument j = " << j << endl;
+  return 0;
+ }
+
+ Int_t lock=0;
+ if (fCalflags)
+ {
+  if (j>0 && j<=(fCalflags->GetSize()))
+  {
+   Int_t word=fCalflags->At(j-1);
+   word=word%10000;
+   lock=word/1000;
+  }
+ }
+ return lock;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetLockValue(TString name) const
+{
+// Provide lock 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=GetLockValue(j);
+ return val;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliAttrib::GetNslots() const
+{
+// Provide the number of existing slots.
+
+  Int_t n=GetNcalflags();
+  Int_t nn=GetNnames();
+  Int_t ncalf=GetNcalfuncs();
+  Int_t ndecalf=GetNdecalfuncs();
+  if (n<nn) n=nn;
+  if (n<ncalf) n=ncalf;
+  if (n<ndecalf) n=ndecalf;
+
+  return n;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliAttrib::AddNamedSlot(TString s)
+{
+// Add a new slot with the specified name.
+// In case a slot with the specified name already exists, no action is taken.
+
+ if (GetSlotIndex(s)) return;
+
+ Int_t n=GetNslots();
+ SetSlotName(s,n+1);
+}
+///////////////////////////////////////////////////////////////////////////
 void AliAttrib::SetSlotName(TString s,Int_t j)
 {
 // Set a user defined name for the j-th (default j=1) slot. 
 // Note : The first attribute slot is at j=1.
+// In case the value of the index j exceeds the maximum number of reserved
+// slots for the names, the number of reserved slots for the names
+// is increased automatically to the corresponding value.
 
  if (j<1) 
  {
@@ -1136,6 +1371,7 @@ void AliAttrib::List(Int_t j) const
   if (GetOffsetFlag(j)) cout << " offset : " << GetOffset(j);
   if (GetEdgeValue(j)) cout << " edge : " << GetEdgeValue(j);
   if (GetDeadValue(j)) cout << " dead : " << GetDeadValue(j);
+  if (GetLockValue(j)) cout << " lock : " << GetLockValue(j);
   if (GetCalFunction(j)) cout << " *Fcalib*";
   if (GetDecalFunction(j)) cout << " *Fdecalib*";
   TString s=GetSlotName(j);
@@ -1161,6 +1397,7 @@ void AliAttrib::List(Int_t j) const
    if (GetOffsetFlag(i))    {cout << " offset : " << GetOffset(i); printf=1;}
    if (GetEdgeValue(i))     {cout << " edge : " << GetEdgeValue(i); printf=1;}
    if (GetDeadValue(i))     {cout << " dead : " << GetDeadValue(i); printf=1;}
+   if (GetLockValue(i))     {cout << " lock : " << GetLockValue(i); printf=1;}
    if (GetCalFunction(i))   {cout << " *Fcalib*"; printf=1;}
    if (GetDecalFunction(i)) {cout << " *Fdecalib*"; printf=1;}
    s=GetSlotName(i);
@@ -1230,6 +1467,14 @@ void AliAttrib::Load(AliAttrib& a,Int_t j)
   for (Int_t ic=1; ic<=n; ic++)
   {
    SetEdgeValue(a.GetEdgeValue(ic),ic);
+   if (a.GetLockValue(ic))
+   {
+    Lock(ic);
+   }
+   else
+   {
+    Unlock(ic);
+   }
    if (a.GetDeadValue(ic))
    {
     SetDead(ic);
@@ -1289,6 +1534,14 @@ void AliAttrib::Load(AliAttrib& a,Int_t j)
   if (j<=n)
   {
    SetEdgeValue(a.GetEdgeValue(j),j);
+   if (a.GetLockValue(j))
+   {
+    Lock(j);
+   }
+   else
+   {
+    Unlock(j);
+   }
    if (a.GetDeadValue(j))
    {
     SetDead(j);
@@ -1339,8 +1592,13 @@ Int_t AliAttrib::GetNcalfuncs() const
 {
 // Provide the number of specified calib. functions for this attribute.
 
+ if (!fCalfuncs) return 0;
+
  Int_t n=0;
- if (fCalfuncs) n=fCalfuncs->GetSize();
+ for (Int_t i=1; i<=fCalfuncs->GetSize(); i++)
+ {
+  if (fCalfuncs->At(i-1)) n=i;
+ }
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -1348,8 +1606,13 @@ Int_t AliAttrib::GetNdecalfuncs() const
 {
 // Provide the number of specified de-calib. functions for this attribute.
 
+ if (!fDecalfuncs) return 0;
+
  Int_t n=0;
- if (fDecalfuncs) n=fDecalfuncs->GetSize();
+ for (Int_t i=1; i<=fDecalfuncs->GetSize(); i++)
+ {
+  if (fDecalfuncs->At(i-1)) n=i;
+ }
  return n;
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -1370,7 +1633,7 @@ TF1* AliAttrib::GetCalFunction(TString name) const
 
  TF1* f=0;
  Int_t j=GetSlotIndex(name);
- if (j>0) GetCalFunction(j);
+ if (j>0) f=GetCalFunction(j);
  return f;
 }
 ///////////////////////////////////////////////////////////////////////////
@@ -1455,7 +1718,7 @@ TF1* AliAttrib::GetDecalFunction(TString name) const
 
  TF1* f=0;
  Int_t j=GetSlotIndex(name);
- if (j>0) GetDecalFunction(j);
+ if (j>0) f=GetDecalFunction(j);
  return f;
 }
 ///////////////////////////////////////////////////////////////////////////