]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliDevice.cxx
Prepare for new code
[u/mrichter/AliRoot.git] / RALICE / AliDevice.cxx
index 3e877554a6e7386139219e60e8b0dcd89caef6cf..df83c35d357f1dbab0f8d8e90e0705784797efb2 100644 (file)
@@ -27,6 +27,8 @@
 // =========
 //
 // AliDevice m;
+// // Set user defined status word to indicate e.g. readout electronics version 
+// m.SetStatus(100201);
 // m.SetHitCopy(1);
 // m.SetName("OM123");
 //
@@ -77,6 +79,7 @@
 //- Modified: NvE $Date$ Utrecht University
 ///////////////////////////////////////////////////////////////////////////
 
+#include <cstdlib>
 #include "AliDevice.h"
 #include "Riostream.h"
  
@@ -85,9 +88,11 @@ ClassImp(AliDevice) // Class implementation to enable ROOT I/O
 AliDevice::AliDevice() : AliSignal()
 {
 // Default constructor.
+// The user definable status word is set to zero.
 // By default private copies of the recorded hits will be made.
 // This implies that by default the device will own the registered hits.
 // See the SetHitCopy() memberfunction for further details.
+ fStatus=0;
  fHitCopy=1;
  fHits=0;
  fOrdered=0;
@@ -136,6 +141,7 @@ AliDevice::AliDevice(const AliDevice& dev) : AliSignal(dev)
  fOrdered=0;
  fMarkers=0;
 
+ fStatus=dev.GetStatus();
  fHitCopy=dev.GetHitCopy();
 
  Int_t nhits=dev.GetNhits();
@@ -165,6 +171,8 @@ AliDevice::AliDevice(const AliDevice& dev) : AliSignal(dev)
 void AliDevice::Reset(Int_t mode)
 {
 // Reset registered hits and AliSignal attributes.
+// Note : The status word and HitCopy flag are NOT modified.
+//        Use SetStatus() and SetHitCopy() to modify these parameters. 
 // See AliSignal::Reset() for further details.
  RemoveHits();
  AliSignal::Reset(mode);
@@ -206,6 +214,18 @@ Int_t AliDevice::GetHitCopy() const
  return fHitCopy;
 }
 ///////////////////////////////////////////////////////////////////////////
+void AliDevice::SetStatus(Int_t word)
+{
+// Set a user defined status word for this device.
+ fStatus=word;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliDevice::GetStatus() const
+{
+// Provide the user defined status word for this device.
+ return fStatus;
+}
+///////////////////////////////////////////////////////////////////////////
 void AliDevice::AddHit(AliSignal& s)
 {
 // Register an AliSignal object as a hit to this device.
@@ -312,6 +332,28 @@ AliSignal* AliDevice::GetHit(Int_t j) const
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+AliSignal* AliDevice::GetHit(TString name) const
+{
+// Provide the AliSignal object registered as hit with the specified name.
+// Note : The first hit encountered with the specified name will be provided.
+
+ if (!fHits) return 0;
+
+ TString hitname;
+ Int_t nhits=GetNhits();
+ for (Int_t i=0; i<nhits; i++)
+ {
+  AliSignal* sx=(AliSignal*)fHits->At(i);
+  if (sx)
+  {
+   hitname=sx->GetName();
+   if (hitname == name) return sx;
+  }
+ }
+
+ return 0; // No matching name found
+}
+///////////////////////////////////////////////////////////////////////////
 AliSignal* AliDevice::GetIdHit(Int_t id) const
 {
 // Return the hit with unique identifier "id".
@@ -358,11 +400,19 @@ void AliDevice::ShowHit(Int_t j) const
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliDevice::Data(TString f) const
+void AliDevice::Data(TString f,TString u) const
 {
 // Print the device and all registered hit info according to the specified
-// coordinate frame.
- AliSignal::Data(f);
+// coordinate frame f.
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+//     "deg" : angles provided in degrees
+//
+// The defaults are f="car" and u="rad".
+
+ AliSignal::Data(f,u);
  Int_t nhits=GetNhits();
  if (nhits)
  {
@@ -375,14 +425,17 @@ void AliDevice::Data(TString f) const
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,Int_t idx,TObjArray* hits) const
+void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,Int_t idx,TObjArray* hits,Int_t mode) const
 {
 // Provide the min. and max. signal values of an array of hits.
 // The input argument "idx" denotes the index of the signal slots to be investigated.
 // The default is idx=1;
 // In case hits=0 (default), the registered hits of the current device are used. 
 // Signals which were declared as "Dead" will be rejected.
-// The gain etc... corrected signals will be used in the process.
+// The gain etc... corrected signals will be used in the process as specified
+// by the  "mode" argument. The definition of this "mode" parameter corresponds to
+// the description provided in the GetSignal memberfunction of class AliSignal.
+// The default is mode=1 (for backward compatibility reasons).
 
  vmin=0;
  vmax=0;
@@ -402,7 +455,7 @@ void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,Int_t idx,TObjArray* hit
   if (idx > sx->GetNvalues()) continue; // User specified slotindex out of range for this signal
   if (sx->GetDeadValue(idx)) continue;  // Only take alive signals
 
-  sig=sx->GetSignal(idx,1);
+  sig=sx->GetSignal(idx,mode);
   if (i==0)
   {
    vmin=sig;
@@ -416,13 +469,16 @@ void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,Int_t idx,TObjArray* hit
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,TString name,TObjArray* hits) const
+void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,TString name,TObjArray* hits,Int_t mode) const
 {
 // Provide the min. and max. signal values of an array of hits.
 // The input argument "name" denotes the name of the signal slots to be investigated.
 // In case hits=0 (default), the registered hits of the current device are used. 
 // Signals which were declared as "Dead" will be rejected.
-// The gain etc... corrected signals will be used in the process.
+// The gain etc... corrected signals will be used in the process as specified
+// by the  "mode" argument. The definition of this "mode" parameter corresponds to
+// the description provided in the GetSignal memberfunction of class AliSignal.
+// The default is mode=1 (for backward compatibility reasons).
 
  vmin=0;
  vmax=0;
@@ -448,7 +504,7 @@ void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,TString name,TObjArray*
 
   if (sx->GetDeadValue(idx)) continue; // Only take alive signals
 
-  sig=sx->GetSignal(idx,1);
+  sig=sx->GetSignal(idx,mode);
   if (i==0)
   {
    vmin=sig;
@@ -462,7 +518,7 @@ void AliDevice::GetExtremes(Float_t& vmin,Float_t& vmax,TString name,TObjArray*
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-TObjArray* AliDevice::SortHits(Int_t idx,Int_t mode,TObjArray* hits)
+TObjArray* AliDevice::SortHits(Int_t idx,Int_t mode,TObjArray* hits,Int_t mcal)
 {
 // Order the references to an array of hits by looping over the input array "hits"
 // and checking the signal value. The ordered array is returned as a TObjArray.
@@ -475,7 +531,11 @@ TObjArray* AliDevice::SortHits(Int_t idx,Int_t mode,TObjArray* hits)
 // order (mode=-1) or ordering in increasing order (mode=1).
 // The default is mode=-1.
 // Signals which were declared as "Dead" will be rejected.
-// The gain etc... corrected signals will be used in the ordering process.
+// The gain etc... corrected signals will be used in the ordering process as
+// specified by the "mcal" argument. The definition of this "mcal" parameter
+// corresponds to the signal correction mode described in the GetSignal
+// memberfunction of class AliSignal.
+// The default is mcal=1 (for backward compatibility reasons).
 
  if (fOrdered)
  {
@@ -523,8 +583,8 @@ TObjArray* AliDevice::SortHits(Int_t idx,Int_t mode,TObjArray* hits)
     break; // go for next hit
    }
  
-   if (mode==-1 && s->GetSignal(idx,1) < ((AliSignal*)fOrdered->At(j))->GetSignal(idx,1)) continue;
-   if (mode==1 && s->GetSignal(idx,1) > ((AliSignal*)fOrdered->At(j))->GetSignal(idx,1)) continue;
+   if (mode==-1 && s->GetSignal(idx,mcal) <= ((AliSignal*)fOrdered->At(j))->GetSignal(idx,mcal)) continue;
+   if (mode==1 && s->GetSignal(idx,mcal) >= ((AliSignal*)fOrdered->At(j))->GetSignal(idx,mcal)) continue;
  
    nord++;
    for (Int_t k=nord-1; k>j; k--) // create empty position
@@ -532,13 +592,13 @@ TObjArray* AliDevice::SortHits(Int_t idx,Int_t mode,TObjArray* hits)
     fOrdered->AddAt(fOrdered->At(k-1),k);
    }
    fOrdered->AddAt(s,j); // put hit at empty position
-   break; // go for next matrix module
+   break; // go for next hit
   }
  }
  return fOrdered;
 }
 ///////////////////////////////////////////////////////////////////////////
-TObjArray* AliDevice::SortHits(TString name,Int_t mode,TObjArray* hits)
+TObjArray* AliDevice::SortHits(TString name,Int_t mode,TObjArray* hits,Int_t mcal)
 {
 // Order the references to an array of hits by looping over the input array "hits"
 // and checking the signal value. The ordered array is returned as a TObjArray.
@@ -551,7 +611,11 @@ TObjArray* AliDevice::SortHits(TString name,Int_t mode,TObjArray* hits)
 // order (mode=-1) or ordering in increasing order (mode=1).
 // The default is mode=-1.
 // Signals which were declared as "Dead" will be rejected.
-// The gain etc... corrected signals will be used in the ordering process.
+// The gain etc... corrected signals will be used in the ordering process as
+// specified by the "mcal" argument. The definition of this "mcal" parameter
+// corresponds to the signal correction mode described in the GetSignal
+// memberfunction of class AliSignal.
+// The default is mcal=1 (for backward compatibility reasons).
 
  if (fOrdered)
  {
@@ -604,8 +668,8 @@ TObjArray* AliDevice::SortHits(TString name,Int_t mode,TObjArray* hits)
     break; // go for next hit
    }
  
-   if (mode==-1 && s->GetSignal(idx,1) < ((AliSignal*)fOrdered->At(j))->GetSignal(idx,1)) continue;
-   if (mode==1 && s->GetSignal(idx,1) > ((AliSignal*)fOrdered->At(j))->GetSignal(idx,1)) continue;
+   if (mode==-1 && s->GetSignal(idx,mcal) <= ((AliSignal*)fOrdered->At(j))->GetSignal(idx,mcal)) continue;
+   if (mode==1 && s->GetSignal(idx,mcal) >= ((AliSignal*)fOrdered->At(j))->GetSignal(idx,mcal)) continue;
  
    nord++;
    for (Int_t k=nord-1; k>j; k--) // create empty position
@@ -613,13 +677,13 @@ TObjArray* AliDevice::SortHits(TString name,Int_t mode,TObjArray* hits)
     fOrdered->AddAt(fOrdered->At(k-1),k);
    }
    fOrdered->AddAt(s,j); // put hit at empty position
-   break; // go for next matrix module
+   break; // go for next hit
   }
  }
  return fOrdered;
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliDevice::DisplayHits(Int_t idx,Float_t scale,TObjArray* hits,Int_t dp,Int_t mstyle,Int_t mcol)
+void AliDevice::DisplayHits(Int_t idx,Float_t scale,TObjArray* hits,Int_t dp,Int_t mode,Int_t mcol)
 {
 // 3D color display of an array hits.
 // The user can specify the index (default=1) of the signal slot to perform the display for.
@@ -631,11 +695,14 @@ void AliDevice::DisplayHits(Int_t idx,Float_t scale,TObjArray* hits,Int_t dp,Int
 // Note that the input array is not modified.
 // In case dp=1 the device position will be used, otherwise the hit position will
 // be used in the display. The default is dp=0.
-// Via the "mstyle" and "mcol" arguments the user can specify the marker style
-// and color (see TPolyMarker3D) respectively.
-// The defaults are mstyle="large scalable dot" and mcol=blue.
+// Via the "mcol" argument the user can specify the marker color (see TPolyMarker3D).
+// The default is mcol=blue.
 // Signals which were declared as "Dead" will not be displayed.
 // The gain etc... corrected signals will be used to determine the marker size.
+// The gain correction is performed according to "mode" argument. The definition of this
+// "mode" parameter corresponds to the description provided in the GetSignal
+// memberfunction of class AliSignal.
+// The default is mode=1 (for backward compatibility reasons).
 //
 // Note :
 // ------
@@ -663,7 +730,7 @@ void AliDevice::DisplayHits(Int_t idx,Float_t scale,TObjArray* hits,Int_t dp,Int
  if (scale<0)
  {
   Float_t vmin,vmax;
-  GetExtremes(vmin,vmax,idx,hits);
+  GetExtremes(vmin,vmax,idx,hits,mode);
   sigmax=fabs(vmax);
   if (fabs(vmin)>sigmax) sigmax=fabs(vmin);
  }
@@ -698,9 +765,13 @@ void AliDevice::DisplayHits(Int_t idx,Float_t scale,TObjArray* hits,Int_t dp,Int
     if (dev) dev->GetPosition(pos,"car");
    }
   }
-  sig=sx->GetSignal(idx,1);
+  sig=sx->GetSignal(idx,mode);
+
+  // Skip dead signals
+  if (fabs(sig) <= 0.) continue;
+
   TPolyMarker3D* m=new TPolyMarker3D();
-  m->SetMarkerStyle(mstyle);
+  m->SetMarkerStyle(8);
   m->SetMarkerColor(mcol);
   m->SetMarkerSize(100.*fabs(sig)/sigmax);
   m->SetPoint(0,pos[0],pos[1],pos[2]);
@@ -709,7 +780,7 @@ void AliDevice::DisplayHits(Int_t idx,Float_t scale,TObjArray* hits,Int_t dp,Int
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliDevice::DisplayHits(TString name,Float_t scale,TObjArray* hits,Int_t dp,Int_t mstyle,Int_t mcol)
+void AliDevice::DisplayHits(TString name,Float_t scale,TObjArray* hits,Int_t dp,Int_t mode,Int_t mcol)
 {
 // 3D color display of an array hits.
 // The user can specify the name of the signal slot to perform the display for.
@@ -723,11 +794,14 @@ void AliDevice::DisplayHits(TString name,Float_t scale,TObjArray* hits,Int_t dp,
 // be used in the display. The default is dp=0.
 // The marker size will indicate the percentage of the maximum encountered value
 // of the absolute value of the name-specified input signal slots.
-// Via the "mstyle" and "mcol" arguments the user can specify the marker style
-// and color (see TPolyMarker3D) respectively.
-// The defaults are mstyle="large scalable dot" and mcol=blue.
+// Via the "mcol" argument the user can specify the marker color (see TPolyMarker3D).
+// The default is mcol=blue.
 // Signals which were declared as "Dead" will not be displayed.
 // The gain etc... corrected signals will be used to determine the marker size.
+// The gain correction is performed according to "mode" argument. The definition of this
+// "mode" parameter corresponds to the description provided in the GetSignal
+// memberfunction of class AliSignal.
+// The default is mode=1 (for backward compatibility reasons).
 //
 // Note :
 // ------
@@ -756,7 +830,7 @@ void AliDevice::DisplayHits(TString name,Float_t scale,TObjArray* hits,Int_t dp,
  if (scale<0)
  {
   Float_t vmin,vmax;
-  GetExtremes(vmin,vmax,name,hits);
+  GetExtremes(vmin,vmax,name,hits,mode);
   sigmax=fabs(vmax);
   if (fabs(vmin)>sigmax) sigmax=fabs(vmin);
  }
@@ -794,9 +868,13 @@ void AliDevice::DisplayHits(TString name,Float_t scale,TObjArray* hits,Int_t dp,
     if (dev) dev->GetPosition(pos,"car");
    }
   }
-  sig=sx->GetSignal(idx,1);
+  sig=sx->GetSignal(idx,mode);
+
+  // Skip dead signals
+  if (fabs(sig) <= 0.) continue;
+
   TPolyMarker3D* m=new TPolyMarker3D();
-  m->SetMarkerStyle(mstyle);
+  m->SetMarkerStyle(8);
   m->SetMarkerColor(mcol);
   m->SetMarkerSize(100.*fabs(sig)/sigmax);
   m->SetPoint(0,pos[0],pos[1],pos[2]);