]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliSignal.cxx
Make and print an image of QA user flagged histograms (Yves)
[u/mrichter/AliRoot.git] / RALICE / AliSignal.cxx
index 9c4ab08b214e25f83137920a26aa045404bb279f..c6bdd25139ce54abc4f520f2ea05ba394a05596f 100644 (file)
 //- Modified: NvE $Date$ UU-SAP Utrecht
 ///////////////////////////////////////////////////////////////////////////
 
+#include <cstdlib>
 #include "AliSignal.h"
 #include "AliTrack.h"
 #include "Riostream.h"
@@ -186,22 +187,29 @@ AliSignal::AliSignal(const AliSignal& s) : TNamed(s),AliPosition(s),AliAttrib(s)
 
  Int_t n=s.GetNvalues();
  Double_t val;
+ Int_t lock;
  for (Int_t i=1; i<=n; 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++)
  {
-  if (s.GetErrorFlag(i))
+  if (s.GetErrorFlag(j))
   {
    val=s.GetSignalError(j);
+   lock=s.GetLockValue();
+   if (lock) Unlock();
    SetSignalError(val,j);
+   if (lock) Lock();
   }
  }
 
@@ -299,15 +307,15 @@ void AliSignal::ResetSignals(Int_t mode)
 {
 // 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;
@@ -317,7 +325,7 @@ void AliSignal::ResetSignals(Int_t mode)
  Int_t sflag=0;
  Int_t eflag=0;
 
- if (fSignals && (mode==0 || mode==1))
+ if (fSignals && (abs(mode)==0 || abs(mode)==1))
  {
   for (Int_t i=1; i<=fSignals->GetSize(); i++)
   {
@@ -327,7 +335,7 @@ void AliSignal::ResetSignals(Int_t mode)
   }
  }
 
- if (fDsignals && (mode==0 || mode==2))
+ if (fDsignals && (abs(mode)==0 || abs(mode)==2))
  {
   for (Int_t j=1; j<=fDsignals->GetSize(); j++)
   {
@@ -337,35 +345,35 @@ void AliSignal::ResetSignals(Int_t mode)
   }
  }
 
- 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;
@@ -379,7 +387,7 @@ void AliSignal::DeleteSignals(Int_t mode)
   delete fSigflags;
   fSigflags=0;
  }
- else if (mode==1)
+ else if (abs(mode)==1)
  {
   for (Int_t i=1; i<=fSigflags->GetSize(); i++)
   {
@@ -387,7 +395,7 @@ void AliSignal::DeleteSignals(Int_t mode)
    SetSigFlags(0,eflag,i);
   }
  }
- else if (mode==2)
+ else if (abs(mode)==2)
  {
   for (Int_t j=1; j<=fSigflags->GetSize(); j++)
   {
@@ -396,21 +404,29 @@ void AliSignal::DeleteSignals(Int_t mode)
   }
  }
 
- DeleteWaveform(0);
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();
@@ -430,6 +446,13 @@ 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.
@@ -437,17 +460,28 @@ void AliSignal::SetSignal(Double_t sig,TString name)
 // 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);
@@ -472,6 +506,13 @@ 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.
@@ -479,7 +520,10 @@ void AliSignal::AddSignal(Double_t sig,TString name)
 // 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
@@ -669,15 +713,23 @@ Float_t AliSignal::GetSignal(TString name,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();
@@ -697,6 +749,13 @@ 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.
@@ -704,7 +763,10 @@ void AliSignal::SetSignalError(Double_t dsig,TString name)
 // 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