]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTHOMERBlockDesc.cxx
Add the AD detector in AliHLTReadoutList
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERBlockDesc.cxx
index adfffb72b571fc6d71ab6a80b19728cd66451e3b..3e2262effdbd12cec1c2ca885ed6eac4882a49c3 100644 (file)
@@ -1,3 +1,4 @@
+// $Id$
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
 // or
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 
-#if __GNUC__>= 3
-   using namespace std;
-#endif
-
 #include "AliHLTHOMERBlockDesc.h"
+
 #include "AliHLTMessage.h"
 
 #include "TMath.h"
 #include "TClass.h"
 
-
 ClassImp(AliHLTHOMERBlockDesc)
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor 
+ * --------------------------------------------------------------------------------- 
+ */
+
 //##################################################################################
 AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
   fData(NULL),
   fSize(0),
+  fBlockName(),
   fIsTObject(kFALSE),
   fIsRawData(kFALSE),
   fMessage(NULL),
+  fTObject(NULL),
   fClassName(),
+  fDataType(),
   fDetector(),
-  fSubDetector(),
-  fSubSubDetector(),
   fSpecification(0),
-  fDataType(),
+  fSubDetector(0),
+  fSubSubDetector(0),
   fHasSubDetectorRange(kFALSE),
   fHasSubSubDetectorRange(kFALSE) {
   // see header file for class documentation
@@ -60,29 +65,6 @@ AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-//##################################################################################
-AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc( void * data, ULong_t size, TString origin, 
-                                           TString dataType, ULong_t specification ) :
-  fData(data),
-  fSize(size),
-  fIsTObject(kFALSE),
-  fIsRawData(kFALSE),
-  fMessage(NULL),
-  fClassName(),
-  fDetector(origin),
-  fSubDetector(),
-  fSubSubDetector(), 
-  fSpecification(specification),
-  fDataType(dataType),
-  fHasSubDetectorRange(kFALSE),
-  fHasSubSubDetectorRange(kFALSE) {
-  // see header file for class documentation
-  
-  // -- Set block parameters
-  SetBlockParameters();
-
-} 
-
 //##################################################################################
 AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
   // see header file for class documentation
@@ -90,120 +72,139 @@ AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
   if ( fMessage != NULL )
     delete fMessage;
   fMessage = NULL;
+
+  if ( fData )
+    delete [] fData;
+  fData = NULL;
+
+  if ( fTObject ) 
+    delete fTObject;
+  fTObject = NULL;
 }
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Data Handling - Setter - public
+ * --------------------------------------------------------------------------------- 
+ */
+
 //##################################################################################
 void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin, 
                                     TString dataType, ULong_t specification ) {
   // see header file for class documentation
 
-  fData = data;
+  fData = new Char_t[size];
+  memcpy( fData, data, size);
+  
   fSize = size;
   fDetector = origin; 
   fDataType = dataType;
   fSpecification = specification; 
 
+  fBlockName.Form("%s_%s_0x%08lX", fDetector.Data(), fDataType.Data(), fSpecification ); 
+
   // -- Set block parameters
   SetBlockParameters();
 
   return;
 }
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Data Handling - private
+ * --------------------------------------------------------------------------------- 
+ */
+
 //##################################################################################
 void AliHLTHOMERBlockDesc::SetBlockParameters() {
   // see header file for class documentation
 
-  Int_t iError = 0;
-
-  // ---- SET CLASS NAME, DATA CONTENTS ----
-
-  // -- Check if block contains raw data
-  if ( ! CheckIfRawData() ) {
-
-    // -- Check if block contains TObject  
-    if ( ! CheckIfTObject() ) {
-
-      // -- Contains arbitrary data type
-      
-      // **** TPC ****
-      if ( ! fDetector.CompareTo("TPC") ) {
-       
-       if ( ! fDataType.CompareTo("CLUSTERS") )
-         fClassName = "AliHLTTPCSpacePoints";
-       else 
-         iError = 1;
-      }
-
-      // **** TRD ****
-      
-      else if ( ! fDetector.CompareTo("TRD") ) {
-       iError = 1;
-      }
-
-      // **** PHOS ****
-      
-      else if ( ! fDetector.CompareTo("PHOS") ) {
-       iError = 1;
-      }
-
-      // **** MUON ****
-      
-      else if ( ! fDetector.CompareTo("MUON") ) {
-       iError = 1;
-      }
-
-      // **** OTHER ****
+  //Int_t iResult = 0;
 
-      else {
-       iError = 1;
-      }
-    }
-  } // if ( ! CheckIfRawData() ) {
-  
-  // -- Check if Data Type has been defined
-  if ( iError ) {
-    //AliError( Form("The data type %s for the detector %s has not been defined yet.", 
-    //            fDataType.Data(), fDetector.Data()) );
-  }
-  
   // ---- SET SPECIFICATIONS ----
-  // -- Convert Specification to "SubDetector/SubSubDetector"
+  // ----------------------------
 
   // **** TPC **** ( has special treatment )
-
   if ( ! fDetector.CompareTo("TPC") ) {
-
+    
     Int_t minPatch  = (fSpecification & 0x000000FF);
     Int_t maxPatch  = (fSpecification & 0x0000FF00) >> 8;
     Int_t minSector = (fSpecification & 0x00FF0000) >> 16 ;
     Int_t maxSector = (fSpecification & 0xFF000000) >> 24;
     
-    fSubDetector += minSector;
-    fSubSubDetector += minPatch;
-  
+    fSubDetector = minSector;
+    fSubSubDetector = minPatch;
+    
     // -- check for ranges
     if ( minSector != maxSector )
       fHasSubDetectorRange = kTRUE;
 
     if ( minPatch != maxPatch )
       fHasSubSubDetectorRange = kTRUE;
+    
   }
-  
   // **** OTHER DETECTORS ****
-  
   else {
-    
+      
     if ( fSpecification ) {
-      // find the max bin which is set to 1
-      fSubDetector += TMath::FloorNint( TMath::Log2(fSpecification) );
-
+       // find the max bin which is set to 1
+      fSubDetector = TMath::FloorNint( TMath::Log2(fSpecification) );
+      
       // -- check for ranges
-      if ( TMath::Log2(fSpecification) != ( (Double_t) TMath::FloorNint( TMath::Log2(fSpecification) ) ) )
+      if ( TMath::Log2(fSpecification) != 
+          static_cast<Double_t>(TMath::FloorNint(TMath::Log2(fSpecification))) )
        fHasSubDetectorRange = kTRUE;
-
     }
   }
 
+  // ---- SET CLASS NAME, DATA CONTENTS ----
+  // ---------------------------------------
+
+  // -- Check if block contains raw data
+  if ( CheckIfRawData() )
+    return;
+
+  // -- Check if block contains TObject  
+  if ( CheckIfTObject() )
+    return;
+
+  // -- Contains arbitrary data type
+      
+  // **** TPC ****
+  if ( ! fDetector.CompareTo("TPC") ) {
+    
+    if ( ! fDataType.CompareTo("CLUSTERS") )
+      fClassName = "AliHLTTPCSpacePoints";
+    //else 
+    //  iResult = -1;
+  }
+  /*
+  // **** TRD ****
+  else if ( ! fDetector.CompareTo("TRD") ) {
+    iResult = -1;
+  }
+  
+  // **** PHOS ****
+  else if ( ! fDetector.CompareTo("PHOS") ) {
+    iResult = -1;
+  }
+  
+  // **** MUON ****
+  else if ( ! fDetector.CompareTo("MUON") ) {
+    iResult = -1;
+  }
+  
+  // **** OTHER ****
+  else {
+    iResult = -1;
+  }
+  */
+  
+  // -- Check if classname has been defined
+  //  if ( iResult < 0 ) {
+    //   AliWarning( Form("The classname for data type %s for the detector %s has not been defined yet.", 
+    //      fDataType.Data(), fDetector.Data()) );
+  // }
   return;
 }
   
@@ -225,10 +226,15 @@ Bool_t AliHLTHOMERBlockDesc::CheckIfTObject() {
   fMessage = new AliHLTMessage( fData, fSize );
   
   // -- Check if TMessage payload is TObject
-  if ( fMessage->What() == kMESS_OBJECT ) {
+  if ( fMessage->What() == kMESS_OBJECT and fMessage->GetClass() != NULL and fMessage->GetClass() != (TClass*)-1)
+  {
     fClassName = fMessage->GetClass()->GetName();
     fIsTObject = kTRUE;
+    
+    fTObject = fMessage->ReadObject( fMessage->GetClass() );
   }
+  
+  fMessage->Reset();
 
   return fIsTObject;
 }
@@ -242,16 +248,4 @@ Bool_t AliHLTHOMERBlockDesc::CheckIfRawData() {
 
   return fIsRawData;
 }
-//##################################################################################
-TObject* AliHLTHOMERBlockDesc::GetTObject() {
-  // see header file for class documentation
-  
-  if ( fMessage ) {
-    TObject* obj = fMessage->ReadObject( fMessage->GetClass() );
-    fMessage->Reset();
-    return obj;
-  }
- else
-   return NULL;
-}
+