]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- Reverting bad changes
authorodjuvsla <odjuvsla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Oct 2009 12:47:23 +0000 (12:47 +0000)
committerodjuvsla <odjuvsla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Oct 2009 12:47:23 +0000 (12:47 +0000)
HLT/PHOS/AliHLTPHOSRawAnalyzerComponentv3.cxx
HLT/PHOS/AliHLTPHOSRawAnalyzerComponentv3.h

index 46963f7e8e967aae3da86408c594fc55d143f0f7..8372987ca6796c8270a92aa7c820ecba7dd3dfae 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+#include "AliHLTPHOSRawAnalyzer.h"
 #include "AliHLTPHOSRawAnalyzerComponentv3.h"
+#include "AliHLTPHOSChannelDataHeaderStruct.h"
+#include "AliHLTPHOSChannelDataStruct.h"
 #include "AliHLTPHOSMapper.h"
-#include "AliHLTPHOSDefinitions.h"
+#include "AliHLTPHOSSanityInspector.h"
+
+#include "AliAltroRawStreamV3.h"
+#include "AliCaloRawStreamV3.h"
+#include "AliRawReaderMemory.h"
+
+
 #include "AliHLTPHOSUtilities.h"
 
 AliHLTPHOSRawAnalyzerComponentv3::AliHLTPHOSRawAnalyzerComponentv3():
-  AliHLTCaloRawAnalyzerComponentv3()
+  AliHLTPHOSRcuProcessor(), 
+  fAnalyzerPtr(0), 
+  fMapperPtr(0), 
+  fSanityInspectorPtr(0),
+  fRawReaderMemoryPtr(0),
+  fAltroRawStreamPtr(0),
+  fAlgorithm(0),
+  fOffset(0),
+  fBunchSizeCut(0),
+  fMinPeakPosition(0),
+  fMaxPeakPosition(100),
+  fkDoPushRawData(true),
+
+  fRawDataWriter(0)
 {
   //comment
+  fMapperPtr = new AliHLTPHOSMapper();
+
+  fRawReaderMemoryPtr = new AliRawReaderMemory();
+
+  fAltroRawStreamPtr = new AliAltroRawStreamV3(fRawReaderMemoryPtr);
+
+  fSanityInspectorPtr = new AliHLTPHOSSanityInspector();
+
+  if( fkDoPushRawData == true  )
+    {
+      
+      fRawDataWriter  = new AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter();
+
+    }
+
 }
 
 
 AliHLTPHOSRawAnalyzerComponentv3::~AliHLTPHOSRawAnalyzerComponentv3()
 {
   //comment
+  Deinit();
 }
 
 int 
 AliHLTPHOSRawAnalyzerComponentv3::Deinit()
 {
   //comment
+  if(fAnalyzerPtr)
+    {
+      delete fAnalyzerPtr;
+      fAnalyzerPtr = 0;
+    }
+  if(fMapperPtr)
+    {
+      delete  fMapperPtr;
+      fMapperPtr = 0;
+    }
+  if(fRawReaderMemoryPtr)
+    {
+      delete fRawReaderMemoryPtr;
+      fRawReaderMemoryPtr = 0;
+    }
+  if(fAltroRawStreamPtr)
+    {
+      delete fAltroRawStreamPtr;
+      fAltroRawStreamPtr = 0;
+    }
   return 0;
 }
 
+const char* 
+AliHLTPHOSRawAnalyzerComponentv3::GetComponentID()
+{
+  //comment
+  return "PhosRawAnalyzerv3";
+}
+
+
 void
 AliHLTPHOSRawAnalyzerComponentv3::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
 {
@@ -233,24 +299,150 @@ AliHLTPHOSRawAnalyzerComponentv3::WriteRawData(AliHLTPHOSChannelDataStruct*) //d
 }
 
 int
-AliHLTPHOSRawAnalyzerComponentv3::InitMapping( const int spec)
+AliHLTPHOSRawAnalyzerComponentv3::DoInit( int argc, const char** argv )
 { 
 
   //See base class for documentation
   // fPrintInfo = kFALSE;
+  int iResult=0;
+  fMapperPtr = new AliHLTPHOSMapper();
 
-  if(fMapperPtr == 0)
+  for(int i = 0; i < argc; i++)
     {
-      fMapperPtr = new AliHLTPHOSMapper();
+      if(!strcmp("-offset", argv[i]))
+       {
+         fOffset = atoi(argv[i+1]);
+       }
+      if(!strcmp("-bunchsizecut", argv[i]))
+       {
+         fBunchSizeCut = atoi(argv[i+1]);
+       }
+      if(!strcmp("-minpeakposition", argv[i]))
+       {
+         fMinPeakPosition = atoi(argv[i+1]);
+       }
+      if(!strcmp("-maxpeakposition", argv[i]))
+       {
+         fMaxPeakPosition = atoi(argv[i+1]);
+       }  
     }
  
   if(fMapperPtr->GetIsInitializedMapping() == false)
     {
-      HLTError("%d:%d, ERROR, mapping not initialized ", __FILE__, __LINE__ );
-      exit(-2);
+      Logging(kHLTLogFatal, __FILE__ , IntToChar(  __LINE__ ) , "AliHLTPHOSMapper::Could not initialise mapping from file %s, aborting", fMapperPtr->GetFilePath());
+      return -4;
     }
 
   return iResult;
 }
 
 
+
+
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::RawDataWriter() :  //fIsFirstChannel(true),
+                                                                   fRawDataBuffer(0),
+                                                                   fCurrentChannelSize(0),
+                                                                   //    fIsFirstChannel(true),
+                                                                   fBufferIndex(0),
+                                                                   fBufferSize( NZROWSRCU*NXCOLUMNSRCU*ALTROMAXSAMPLES*NGAINS +1000 ),
+                                                                   fCurrentChannelIdPtr(0),
+                                                                   fCurrentChannelSizePtr(0),
+                                                                   fCurrentChannelDataPtr(0),
+                                                                   fTotalSize(0)
+{
+  fRawDataBuffer = new UShort_t[fBufferSize];
+  Init();
+}
+
+
+   
+void  
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::Init()
+{
+  fCurrentChannelIdPtr = fRawDataBuffer;
+  fCurrentChannelSizePtr = fRawDataBuffer +1;
+  fCurrentChannelDataPtr = fRawDataBuffer +2;
+  ResetBuffer();
+}
+
+void
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::NewEvent()
+{
+  Init();
+  fTotalSize = 0;
+}
+
+
+void
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::NewChannel( )
+{
+  *fCurrentChannelSizePtr   = fCurrentChannelSize;
+  fCurrentChannelIdPtr     += fCurrentChannelSize;
+  fCurrentChannelSizePtr    += fCurrentChannelSize;
+  fCurrentChannelDataPtr   += fCurrentChannelSize;
+  fBufferIndex = 0;
+  fCurrentChannelSize = 2;
+  fTotalSize += 2;
+}
+
+
+void 
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::WriteBunchData(const UShort_t *bunchdata,  const int length,   const UInt_t starttimebin )
+{
+  fCurrentChannelDataPtr[fBufferIndex] = starttimebin;
+  fCurrentChannelSize ++;
+  fBufferIndex++;
+  fCurrentChannelDataPtr[fBufferIndex] = length;
+  fCurrentChannelSize ++;
+  fBufferIndex++;
+
+  fTotalSize +=2;
+
+  for(int i=0; i < length; i++)
+    {
+      fCurrentChannelDataPtr[ fBufferIndex + i ] =  bunchdata[i];
+    }
+
+  fCurrentChannelSize += length;
+  fTotalSize += length;
+  fBufferIndex += length;
+}
+
+
+void
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::SetChannelId( const UShort_t channeldid  )
+{
+  *fCurrentChannelIdPtr =  channeldid;
+}
+
+
+void
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::ResetBuffer()
+{
+  for(int i=0; i < fBufferSize ; i++ )
+    {
+      fRawDataBuffer[i] = 0;
+    }
+}
+
+
+int
+AliHLTPHOSRawAnalyzerComponentv3::RawDataWriter::CopyBufferToSharedMemory(UShort_t *memPtr, const int sizetotal, const int sizeused )
+{
+  int sizerequested =  (sizeof(int)*fTotalSize + sizeused);
+
+  if(  sizerequested   > sizetotal  )
+    {
+      return 0;
+  }
+  else
+    {
+      for(int i=0; i < fTotalSize; i++)
+       {
+         memPtr[i] = fRawDataBuffer[i]; 
+       }
+      return fTotalSize;
+   }
+}
+  
index f48ab391f248cfb47a71cfbf433e1f47f3d5abd4..2933f1cbf9937ac7ef3287ae9cc74710a20f9f1f 100644 (file)
@@ -25,7 +25,7 @@
  * @file   AliHLTPHOSRawAnalyzerComponentv3.h
  * @author Oystein Djuvsland
  * @date   
- * @brief  A raw analyzer component for PHOS HLT
+ * @brief  A clusterizer component for PHOS HLT
 */
 
 // see below for class documentation
@@ -53,6 +53,49 @@ class AliHLTPHOSChannelDataStruct;
 
 /**
  * @class AliHLTPHOSRawAnalyzerComponentv3
+ * This the new and fast version of the component taking care of the decoding and energy and timing 
+ * extraction of the raw data from PHOS.
+ *
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b PhosRawAnalyzerv3 <br>
+ * Library: \b libAliHLTPHOS.so     <br>
+ * Input Data Types: @ref <br>
+ * Output Data Types: @ref AliHLTPHOSDefinitions::fgkChannelDataType<br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li No mandatory arguments for component                           <br>
+ *
+ * <h2>Optional arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li -offset      <i> value </i> <br>
+ *      gives the offset added to the data during zero suppression (default value: 0)
+ * \li -bunchsizecut <i> value </i> <br>
+ *      minimum number of samples a bunch must contain to be considered  (default value: 0)
+ * \li -minpeakposition <i> value </i> <br>
+ *      cut on minimum postion of the peak in the bunch (defaul value: 0)
+ * \li -maxpeakposition <i> value </i> <br>
+ *      cut on maximum postion of the peak in the bunch (defaul value: 100)
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * \li No configuration arguments 
+ *
+ * <h2>Default CDB entries:</h2>
+ * \li No CDB entry yet, will come.
+ *
+ * <h2>Performance:</h2>
+ * Pretty good (~ 3 kHz), depends on amount of data...
+ *
+ * <h2>Memory consumption:</h2>
+ * Depends on the amount of data, but pretty godd
+ *
+ * <h2>Output size:</h2>
+ * Depends on the amount of data...
+ *
+ * More detailed description. (Soon)
+ *
  * @ingroup alihlt_phos
  */ 
 
@@ -90,27 +133,107 @@ class AliHLTPHOSRawAnalyzerComponentv3 : public AliHLTPHOSRcuProcessor
 
  protected:
 
+  /** interface function, see @ref AliHLTComponent for description */
+  using AliHLTPHOSRcuProcessor::DoEvent;
+
+  /** interface function, see @ref AliHLTComponent for description */
+  virtual int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
+                    AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                      AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );  
+
   /** 
-   * Check for correct input data type (raw data from PHOS) 
-   * @datatype is the data type specifier
-   * @return true if the data type is correct
+   * Do the real processing in the component 
+   * @param iter is the pointer to the data blocks
+   * @param outputPtr is the pointer to the output buffer
+   * @param size is the available size for output
+   * @param totSize is the total size used for output
+   * @return the size output size used
    */
-  virtual bool CheckInputDataType(const AliHLTComponentDataType &datatype);
+  virtual Int_t DoIt(const AliHLTComponentBlockData* iter, AliHLTUInt8_t* outputPtr, const AliHLTUInt32_t size, UInt_t& totSize); 
+
+
+  /** Pointer to an analyzer object used for raw data anlysis */ 
+  AliHLTPHOSRawAnalyzer *fAnalyzerPtr;   //COMMENT
 
  private:
 
+  int WriteRawData( AliHLTPHOSChannelDataStruct *dtaPtr );
+
   /** Keep the copy constructor private since it should not be used */
   AliHLTPHOSRawAnalyzerComponentv3(const AliHLTPHOSRawAnalyzerComponentv3 & );
 
   /** Keep the assignement operator private since it should not be used */
   AliHLTPHOSRawAnalyzerComponentv3 & operator = (const AliHLTPHOSRawAnalyzerComponentv3 &);
+
+  /** Mapping from harware address to geometrical address */
+  AliHLTPHOSMapper *fMapperPtr;                       //!transient 
+
+  /** Pointer to object which may check the integrity of the data */
+  AliHLTPHOSSanityInspector *fSanityInspectorPtr;     //!transient
+
+  /** Pointer to the raw data reader which reads from memory */
+  AliRawReaderMemory* fRawReaderMemoryPtr;            //!transient
   
-  /** 
-   * Initialise the mapping according to the specification
-   * @specification is the specification provided by the HLT framework
-   */
-  virtual void InitMapping(const int specification);
+  /** Pointer to the raw stream */
+  AliAltroRawStreamV3* fAltroRawStreamPtr;              //!transient
+
+  /** Describing which algorithm we are using */
+  Short_t fAlgorithm;                                 //COMMENT
 
+  /** The offset applied before ZS */
+  Int_t fOffset;                                      //COMMENT
+
+  /** The minimum length a bunch can have to be considered */
+  Int_t fBunchSizeCut;                                //COMMENT
+
+  /** The lowest position a peak can have to be considered */
+  Int_t fMinPeakPosition;                             //COMMENT
+  
+  /** The maximum position a peak can have to be considered */
+  Int_t fMaxPeakPosition;                             //COMMENT
+
+
+  const bool fkDoPushRawData;
+  
+  // const UShort_t* fRawDataBuffer;
+  // RawDataWriter *fRawDataWriter; 
+
+  //  class RawDataWriter : public AliHLTLogging
+  class RawDataWriter 
+  {
+  public:
+    RawDataWriter();
+    ~RawDataWriter();
+    //   void WriteChannelId(const UShort_t channeldid );
+    void NewChannel( );
+    void WriteBunchData(const UShort_t *bunchdata,  const int length,   const UInt_t starttimebin );
+    void ResetBuffer();
+    void SetChannelId( const UShort_t channeldid );
+
+    //void CopyBufferToSharedMemory(UShort_t *memPtr, const int sizetotal, const int sizeused );
+    int CopyBufferToSharedMemory(UShort_t *memPtr, const int sizetotal, const int sizeused );
+  
+ void NewEvent();
+ private:
+    RawDataWriter (const RawDataWriter  & );
+    RawDataWriter & operator = (const RawDataWriter &);
+    
+    void Init();
+    
+    //    bool fIsFirstChannel;
+    UShort_t* fRawDataBuffer;
+    int fCurrentChannelSize;
+    int fBufferIndex;
+    int fBufferSize;
+    UShort_t *fCurrentChannelIdPtr;
+    UShort_t *fCurrentChannelSizePtr; 
+    UShort_t *fCurrentChannelDataPtr; 
+    int fTotalSize;
+ };
+
+  RawDataWriter *fRawDataWriter; 
 
 };