]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDBaseDigit.cxx
Fixes for Coverity + changes to take into account the improvements of the analysis...
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDigit.cxx
index f570effc8d0ce9c9b1b8dd1587722d45d3b1e6e0..6f1356c252a1973faf972520468872a1668d7ac9 100644 (file)
 //////////////////////////////////////////////////////////////////////
 
 #include "AliFMDBaseDigit.h"   // ALIFMDDIGIT_H
+#include "AliFMDStripIndex.h"
 #include "Riostream.h"         // ROOT_Riostream
-#include <TString.h>
-#include <AliLog.h>
+// #include <TString.h>
+// #include <AliLog.h>
+#include "AliFMDDebug.h" // Better debug macros
 
 //====================================================================
 ClassImp(AliFMDBaseDigit)
@@ -79,18 +81,21 @@ AliFMDBaseDigit::AliFMDBaseDigit()
   : fDetector(0), 
     fRing('\0'), 
     fSector(0), 
-    fStrip(0)
+    fStrip(0), 
+    fName("")
 {}
 
 //____________________________________________________________________
 AliFMDBaseDigit::AliFMDBaseDigit(UShort_t detector, 
-                        Char_t   ring, 
-                        UShort_t sector, 
-                        UShort_t strip)
-  : fDetector(detector), 
+                                Char_t   ring, 
+                                UShort_t sector, 
+                                UShort_t strip)
+  : AliDigit(), 
+    fDetector(detector), 
     fRing(ring), 
     fSector(sector), 
-    fStrip(strip)
+    fStrip(strip),
+    fName("")
 {
   //
   // Creates a base data digit object
@@ -103,12 +108,37 @@ AliFMDBaseDigit::AliFMDBaseDigit(UShort_t detector,
   //    strip    Strip # (For inner/outer rings: 0-511/0-255)
 }
 
+//____________________________________________________________________
+AliFMDBaseDigit::AliFMDBaseDigit(Int_t*   tracks, 
+                                UShort_t detector, 
+                                Char_t   ring, 
+                                UShort_t sector, 
+                                UShort_t strip)
+  : AliDigit(tracks), 
+    fDetector(detector), 
+    fRing(ring), 
+    fSector(sector), 
+    fStrip(strip),
+    fName("")
+{
+  //
+  // Creates a base data digit object
+  //
+  // Parameters 
+  //
+  //    tracks    Array of 3 track labels
+  //    detector  Detector # (1, 2, or 3)                      
+  //    ring     Ring ID ('I' or 'O')
+  //    sector   Sector # (For inner/outer rings: 0-19/0-39)
+  //    strip    Strip # (For inner/outer rings: 0-511/0-255)
+}
+
 //____________________________________________________________________
 void
 AliFMDBaseDigit::Print(Option_t* /* option*/) const 
 {
   // Print digit to standard out 
-  cout << ClassName() << ": FMD" << GetName() << flush;
+  cout << ClassName() << ": " << GetName() << flush;
 }
 
 //____________________________________________________________________
@@ -128,9 +158,14 @@ AliFMDBaseDigit::GetName() const
 ULong_t
 AliFMDBaseDigit::Hash() const
 {
+  // Calculate a hash value based on the detector coordinates. 
+#if 1  
+  return AliFMDStripIndex::Pack(fDetector, fRing, fSector, fStrip);
+#else
   size_t ringi = (fRing == 'I' ||  fRing == 'i' ? 0 : 1);
   return fStrip + fMaxStrips * 
     (fSector + fMaxSectors * (ringi + fMaxRings * (fDetector - 1)));
+#endif
 }
 
 
@@ -138,6 +173,18 @@ AliFMDBaseDigit::Hash() const
 Int_t
 AliFMDBaseDigit::Compare(const TObject* o) const
 {
+  // Compare to other digit.  If the passed pointer to TObject does
+  // not point to an object of class AliFMDBaseDigit (or one of it's
+  // derived classes), then a fatal exception is made. 
+  // 
+  // Returns -1, if this object's detector coordinates are smaller
+  // than passed object's detector coordinates. 
+  // 
+  // Returns  0, if this object's detector coordinates is the same as
+  // passed object's detector coordinates.  
+  // 
+  // Returns  1, if this object's detector coordinates are larger
+  // than passed object's detector coordinates. 
   if (!o) 
     AliFatal("Can not compare to NULL!");
   if (o->IsA() != AliFMDBaseDigit::Class()) 
@@ -148,6 +195,28 @@ AliFMDBaseDigit::Compare(const TObject* o) const
   return 1;
 }
 
+//____________________________________________________________________
+void
+AliFMDBaseDigit::AddTrack(Int_t track)
+{
+  if      (fTracks[0] == -1) fTracks[0] = track;
+  else if (fTracks[1] == -1) fTracks[1] = track;
+  else if (fTracks[2] == -1) fTracks[2] = track;
+  else 
+    AliWarning(Form("While adding track label to %s for %s: "
+                   "All 3 track labels used, can't add reference to track %d",
+                   ClassName(), GetName(), track));
+}
+
+//____________________________________________________________________
+UShort_t
+AliFMDBaseDigit::GetNTrack() const
+{
+  for (Int_t i = 3; i > 0; i--) 
+    if (fTracks[i-1] != -1) return i;
+  return 0;
+}
+
 
 //____________________________________________________________________
 //