]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
potential memory leak fixed (Kenneth); sequential (non-bunch) reading implemented...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 15 Feb 2008 12:20:46 +0000 (12:20 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 15 Feb 2008 12:20:46 +0000 (12:20 +0000)
HLT/TPCLib/AliHLTTPCDigitDumpComponent.cxx
HLT/TPCLib/AliHLTTPCDigitDumpComponent.h
HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx
HLT/TPCLib/AliHLTTPCDigitReaderDecoder.h

index 6e81fd9805c1c6ff2a4198da07e86e71d0d5816e..a56fed8498eb7622bea705dbc7fe81b6b30aad2f 100644 (file)
@@ -34,6 +34,7 @@
 #include "AliHLTTPCDigitReaderUnpacked.h"
 #include "AliHLTTPCDigitReaderPacked.h"
 #include "AliHLTTPCDigitReaderRaw.h"
+#include "AliHLTTPCDigitReaderDecoder.h"
 #include "AliHLTTPCDefinitions.h"
 
 #define DefaultRawreaderMode 0
@@ -45,7 +46,7 @@ AliHLTTPCDigitDumpComponent::AliHLTTPCDigitDumpComponent()
   :
   AliHLTFileWriter(),
   fRawreaderMode(DefaultRawreaderMode),
-  fDigitReaderType(kDigitReaderRaw),
+  fDigitReaderType(kDigitReaderDecoder),
   fRcuTrailerSize(2),
   fUnsorted(false)
 {
@@ -119,6 +120,8 @@ int AliHLTTPCDigitDumpComponent::ScanArgument(int argc, const char** argv)
        fDigitReaderType=kDigitReaderPacked;
       } else if (param.CompareTo("raw", TString::kIgnoreCase)==0) {
        fDigitReaderType=kDigitReaderRaw;
+      } else if (param.CompareTo("decoder", TString::kIgnoreCase)==0) {
+       fDigitReaderType=kDigitReaderDecoder;
       } else {
        HLTError("unknown digit reader type %s", param.Data());
        iResult=-EINVAL;
@@ -221,6 +224,10 @@ int AliHLTTPCDigitDumpComponent::DumpEvent( const AliHLTComponentEventData& evtD
          HLTInfo("create DigitReaderRaw");
          pReader=new AliHLTTPCDigitReaderRaw(fRawreaderMode);
          break;
+       case kDigitReaderDecoder:
+         HLTInfo("create DigitReaderDecoder");
+         pReader=new AliHLTTPCDigitReaderDecoder();
+         break;
        }
        if (!pReader) {
          HLTError("can not create digit reader of type %d", fDigitReaderType);
@@ -234,11 +241,13 @@ int AliHLTTPCDigitDumpComponent::DumpEvent( const AliHLTComponentEventData& evtD
        int iPrintedPad=-1;
        int iLastTime=-1;
        while (pReader->Next()) {
-         if ((iPrintedSlice!=-1 && iLastTime!=pReader->GetTime()+1 && iLastTime!=pReader->GetTime()-1) ||
-             (iPrintedPad!=-1 && iPrintedPad!=pReader->GetPad()) ||
-             (iPrintedRow!=-1 && iPrintedRow!=pReader->GetRow())) {
+         if ((iPrintedSlice!=-1 && iLastTime!=-1 && iLastTime!=pReader->GetTime()+1 && iLastTime!=pReader->GetTime()-1)) {
+           dump << "    -> Time: " << iLastTime << endl;
+         } else if ((iPrintedPad!=-1 && iPrintedPad!=pReader->GetPad()) ||
+                    (iPrintedRow!=-1 && iPrintedRow!=pReader->GetRow())) {
            dump << endl;
          }
+
          if (iPrintedSlice!=slice || iPrintedPart!=part) {
            iPrintedSlice=slice;
            iPrintedPart=part;
index 3189b55ed8d5a1b565196bcf8329dcc197b45025..bf1c299660585b1929749548b8f293656a1905eb 100644 (file)
  *
  * Optional arguments: <br>
  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
- * \li -rawreadermode  <i> mode   </i> <br>
- *      data mode of the <b>AliHLTTPCDigitReaderRaw</b> 
  * \li -digitreader    <i> reader   </i> <br>
- *      type of the digit reader: <i>unpacked, packed, raw</i> 
+ *      type of the digit reader: <i>unpacked, packed, raw, decoder</i>
+ *      default 'decoder' 
  * \li -rcutrailersize    <i> size   </i> <br>
- *      size of the RCU trailer in 32bit words (default 2)
+ *      size of the RCU trailer in 32bit words (default 2), if digitreader
+ *      'decoder' is used, the trailer size is determined automatically
+ * \li -rawreadermode  <i> mode   </i> <br>
+ *      data mode of the <b>AliHLTTPCDigitReaderRaw</b> 
  * \li -unsorted <br>
  *      unsorted mode of digit readers (default sorted)
  * \li -sorted <br>
@@ -82,7 +84,8 @@ class AliHLTTPCDigitDumpComponent : public AliHLTFileWriter {
     kDigitReaderInvalid,
     kDigitReaderUnpacked,
     kDigitReaderPacked,
-    kDigitReaderRaw
+    kDigitReaderRaw,
+    kDigitReaderDecoder
   };
 
   /** the mode for the DigitReaderRaw */
index 5779cdad32db2831d24c75e56e13847475ba2fb9..2aa48b1747fedd37a38ebac4affcdfe65f1fd2ec 100644 (file)
@@ -28,6 +28,7 @@
 using namespace std;
 #endif
 
+#include <cassert>
 #include "AliHLTTPCDigitReaderDecoder.h"
 #include "AliHLTTPCMapping.h"
 #include "AliAltroDecoder.h"
@@ -43,7 +44,8 @@ AliHLTTPCDigitReaderDecoder::AliHLTTPCDigitReaderDecoder()
   fAltroData(),
   fAltroBunch(NULL),
   fMapping(NULL),
-  fNextCounter(0),
+  // initialization due to the logic in NextSignals
+  fNextCounter(-1),
   fNextSignalMethodUsed(kFALSE)
 {
   // see header file for class documentation
@@ -70,9 +72,16 @@ AliHLTTPCDigitReaderDecoder::~AliHLTTPCDigitReaderDecoder()
 int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice)
 {
   // see header file for class documentation
-  fMapping = new AliHLTTPCMapping(patch);
-  fAltroDecoder = new AliAltroDecoder();
-  fAltroBunch = new AliAltroBunch();
+  //  HLTDebug("Initializing block in decoder");
+  if(!fMapping){
+    fMapping = new AliHLTTPCMapping(patch);
+  }
+  if(!fAltroDecoder){
+    fAltroDecoder = new AliAltroDecoder();
+  }
+  if(!fAltroBunch){
+    fAltroBunch = new AliAltroBunch();
+  }
   fAltroDecoder->SetMemory((UChar_t*)ptr, size);
   fAltroDecoder->Decode();
   return 0;
@@ -93,24 +102,25 @@ int AliHLTTPCDigitReaderDecoder::NextBunch()
 bool AliHLTTPCDigitReaderDecoder::NextSignal()
 {
   // see header file for class documentation
-  /*  nextSignalMethodUsed=kTRUE;
-  if(!fAltroBunch){      // this is true when NextChannel and Next bunch has not been called yet
-    if(NextChannel()){   // checks if ther is any pads with data
-      if(!NextBunch()){  // checks if there is any bunch
-       return false;
-      }
+  fNextSignalMethodUsed=kTRUE;
+  do {
+    if (fNextCounter>0) {
+      // there is data available in the current bunch
+      fNextCounter--;
+      return true;
     }
-    else{
-      return false;
+
+    // there is no data left in the current bunch, search for the next one
+    while (NextBunch()) if (GetBunchSize()>0) {
+      fNextCounter=GetBunchSize()-1;
+      return true;
     }
-  }
+
+    fNextCounter=-1;
+    // there is no bunch left, go to the next channel
+  } while (NextChannel());
   
-  UInt_t bunchSize=fAltroBunchSize;
-  if(nextCounter==bunchSize){
-    nextCounter=0;
-    return false;
-    }*/
-  return true;
+  return false;
 }
 
 const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals()
@@ -129,12 +139,18 @@ int AliHLTTPCDigitReaderDecoder::GetPad()
 {
   // see header file for class documentation
   return fMapping->GetPad(fAltroData.GetHadd());
-    //    return 0;
 }
 
 int AliHLTTPCDigitReaderDecoder::GetSignal()
 {
   // see header file for class documentation
+  if (fNextSignalMethodUsed) {
+    const  UInt_t* pData=GetSignals();
+    if (pData && fNextCounter>=0) {
+      assert(fNextCounter<GetBunchSize());
+      return pData[fNextCounter];
+    }
+  }
   return 0;
 }
 
@@ -145,11 +161,19 @@ int AliHLTTPCDigitReaderDecoder::GetTime()
     return fAltroBunch->GetStartTimeBin();
   }
   else{
+    assert(fNextCounter>=0);
     return fAltroBunch->GetStartTimeBin()+fNextCounter;
   }
 }
 
 int AliHLTTPCDigitReaderDecoder::GetBunchSize()
 {
+  // see header file for class documentation
   return fAltroBunch->GetBunchSize();
 }
+
+AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const
+{
+  // see header file for class documentation
+  return (AliHLTUInt32_t)fAltroData.GetHadd();
+}
index fd1dfc7c97724e73b69a89d3d4523ab9c203c213..d7e2c51b35d5df2a398e5390147558b78b2add4b 100644 (file)
@@ -50,6 +50,8 @@ public:
   const UInt_t* GetSignals();
   int GetTime();
   int GetBunchSize();
+  AliHLTUInt32_t GetAltroBlockHWaddr() const;
+
 protected:
   bool NextSignal();
 
@@ -64,12 +66,10 @@ private:
   AliAltroBunch *fAltroBunch;                                      //! transient
   AliHLTTPCMapping *fMapping;                                      //! transient
 
-  UInt_t fNextCounter;                                             //! transient
-  Bool_t fNextSignalMethodUsed;                                    //! transient
-
-
+  int fNextCounter;                                                //! transient
+  bool fNextSignalMethodUsed;                                      //! transient
 
-  ClassDef(AliHLTTPCDigitReaderDecoder, 1)
+  ClassDef(AliHLTTPCDigitReaderDecoder, 2)
     
 };
 #endif