Initial version of the RCU ALTRO V3 format encoder. It derives from the old encoder...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Jun 2009 09:05:20 +0000 (09:05 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Jun 2009 09:05:20 +0000 (09:05 +0000)
RAW/AliAltroBuffer.h
RAW/AliAltroBufferV3.cxx [new file with mode: 0644]
RAW/AliAltroBufferV3.h [new file with mode: 0644]
RAW/CMake_libRAWDatasim.txt
RAW/RAWDatasimLinkDef.h
RAW/libRAWDatasim.pkg

index 65e0b482c5526d6eccdebcc2f311e30c331dd786..9ec3de42d610444e1a64c2eae61b58724428c395 100644 (file)
@@ -37,19 +37,19 @@ class AliAltroBuffer: public TObject {
   virtual void  WriteTrailer(Int_t wordsNumber, Short_t hwAddress); 
   //this method is used to write the trailer
 
-  virtual void  WriteChannel(Int_t padNumber, Int_t rowNumber, Int_t secNumber,
+  void  WriteChannel(Int_t padNumber, Int_t rowNumber, Int_t secNumber,
                     Int_t nTimeBins, const Int_t* adcValues, 
                     Int_t threshold = 0);
   //this method is used to write all ADC values and the trailer of a channel
-  virtual void  WriteChannel(Short_t hwAddress,
+  void  WriteChannel(Short_t hwAddress,
                     Int_t nTimeBins, const Int_t* adcValues, 
                     Int_t threshold = 0);
   //this method is used to write all ADC values and the trailer of a channel
-  virtual Int_t WriteBunch(Int_t nTimeBins, const Int_t* adcValues,
+  Int_t WriteBunch(Int_t nTimeBins, const Int_t* adcValues,
                   Int_t threshold = 0);
   //this method is used to write all ADC values
 
-  virtual void  WriteDataHeader(Bool_t dummy, Bool_t compressed);
+  void  WriteDataHeader(Bool_t dummy, Bool_t compressed);
   //this method is used to write the data header
 
   virtual void  WriteRCUTrailer(Int_t rcuId);
@@ -59,7 +59,7 @@ class AliAltroBuffer: public TObject {
   //this method is used to set the verbose level 
   //level  0 no output messages
   //level !=0 some messages are displayed during the run
-  virtual void  Flush();
+  void  Flush();
   //this method is used to fill the buffer with 2AA hexadecimal value and save it into the output file
 
   void  SetMapping(AliAltroMapping *mapping) { fMapping = mapping; }
diff --git a/RAW/AliAltroBufferV3.cxx b/RAW/AliAltroBufferV3.cxx
new file mode 100644 (file)
index 0000000..f2d5fc8
--- /dev/null
@@ -0,0 +1,159 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+// Interface to the Altro format
+// to read and write digits
+// To be used in Alice Data Challenges 
+// and in the compression of the RAW data
+
+#include "AliAltroBufferV3.h"
+#include "AliRawDataHeaderSim.h"
+#include "AliLog.h"
+#include "AliFstream.h"
+
+ClassImp(AliAltroBufferV3)
+
+//_____________________________________________________________________________
+AliAltroBufferV3::AliAltroBufferV3(const char* fileName, AliAltroMapping *mapping):
+AliAltroBuffer(fileName,mapping),
+  fN(0)
+{
+  // Constructor
+}
+
+//_____________________________________________________________________________
+AliAltroBufferV3::~AliAltroBufferV3()
+{
+// destructor
+
+  if (fVerbose) Info("~AliAltroBufferV3", "File Created");
+
+  delete fFile;
+
+}
+
+//_____________________________________________________________________________
+AliAltroBufferV3::AliAltroBufferV3(const AliAltroBufferV3& source):
+  AliAltroBuffer(source),
+  fN(source.fN)
+{
+// Copy Constructor
+
+  Fatal("AliAltroBufferV3", "copy constructor not implemented");
+}
+
+//_____________________________________________________________________________
+AliAltroBufferV3& AliAltroBufferV3::operator = (const AliAltroBufferV3& /*source*/)
+{
+//Assigment operator
+
+  Fatal("operator =", "assignment operator not implemented");
+  return *this;
+}
+
+//_____________________________________________________________________________
+void AliAltroBufferV3::FillBuffer(Int_t val)
+{
+//Fills the Buffer with 16 ten bits words and write into a file 
+
+  if ((val > 0x3FF) || (val < 0)) {
+    Error("FillBuffer", "Value out of range (10 bits): %d", val);
+    val = 0x3FF;
+  }
+
+  if (fN >= (kMaxWords-1)) {
+    Error("FillBuffer","Altro channel can't have more than 1024 10-bit words!");
+    return;
+  }
+
+  fArray[fN++] = val;
+}
+
+//_____________________________________________________________________________
+void AliAltroBufferV3::WriteTrailer(Int_t wordsNumber, Short_t hwAddress)
+{
+  //Writes a trailer (header) of 32 bits using
+  //a given hardware adress
+  UInt_t temp = hwAddress & 0xFFF;
+  temp = (wordsNumber << 16) & 0x3FF;
+  temp |= (0x1 << 30);
+
+  fFile->WriteBuffer((char *)(&temp),sizeof(UInt_t));
+
+  ReverseAndWrite();
+}
+
+//_____________________________________________________________________________
+void AliAltroBufferV3::ReverseAndWrite()
+{
+  // Reverse the altro data order and
+  // write the buffer to the file
+  UInt_t temp = 0;
+  Int_t shift = 20;
+  for(Int_t i = fN; i >= 0; i--) {
+    temp |= (fArray[i] << shift);
+    shift -= 10;
+    if (shift < 0) {
+      fFile->WriteBuffer((char *)(&temp),sizeof(UInt_t));
+      temp = 0;
+      shift = 20;
+    }
+  }
+
+  if (shift != 20) {
+    fFile->WriteBuffer((char *)(&temp),sizeof(UInt_t));
+  }
+
+  fN = 0;
+}
+
+//_____________________________________________________________________________
+void AliAltroBufferV3::WriteRCUTrailer(Int_t rcuId)
+{
+  // Writes the RCU trailer
+  // rcuId the is serial number of the corresponding
+  // RCU. The basic format of the trailer can be
+  // found in the RCU manual.
+  // This method should be called at the end of
+  // raw data writing.
+
+  UInt_t currentFilePos = fFile->Tellp();
+  UInt_t size = currentFilePos-fDataHeaderPos;
+  size -= sizeof(AliRawDataHeader);
+  
+  if ((size % 5) != 0) {
+    AliFatal(Form("The current raw data payload is not a mutiple of 5 (%d) ! Can not write the RCU trailer !",size));
+    return;
+  }
+
+  // Now put the size in unit of number of 40bit words
+  size /= 5;
+  fFile->WriteBuffer((char *)(&size),sizeof(UInt_t));
+
+  // Now several not yet full defined fields
+  // In principle they are supposed to contain
+  // information about the sampling frequency,
+  // L1 phase, list of 'dead' FECs, etc.
+  //  UInt_t buffer[n];
+  //  fFile->WriteBuffer((char *)(buffer),sizeof(UInt_t)*n);
+  
+  //  Now the RCU identifier and size of the trailer
+  //  FOr the moment the triler size is 2 32-bit words
+  UInt_t buffer = (2 & 0x7F);
+  buffer |= ((rcuId & 0x1FF) << 7);
+  buffer |= 0xAAAA << 16;
+  fFile->WriteBuffer((char *)(&buffer),sizeof(UInt_t));
+
+}
diff --git a/RAW/AliAltroBufferV3.h b/RAW/AliAltroBufferV3.h
new file mode 100644 (file)
index 0000000..886f733
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/////////////////////////////////////////////////////
+// Class used for read-write the ALTRO data format //
+/////////////////////////////////////////////////////
+
+/*This class is an interface between the altro format file and the 
+  user, and can be used in write or read mode
+  In the write mode a new altro file is created and filled using the method FillBuffer().
+  The name of the file is specified as parameter in the constructor as well as the type mode.
+  In the Read mode the specified file is open and the values can be read using the
+  methods GetNext() and GetNextBackWord().
+  The first method is used to read the file forward while the second is used to read backward 
+*/
+
+#ifndef AliALTROBUFFERV3_H
+#define AliALTROBUFFERV3_H
+
+#include "AliAltroBuffer.h"
+
+class AliAltroBufferV3: public AliAltroBuffer {
+ public:
+  AliAltroBufferV3(const char* fileName, AliAltroMapping *mapping = NULL);
+  virtual ~AliAltroBufferV3();
+
+  virtual void  FillBuffer(Int_t val);
+  //this method stores a word into the buffer
+
+  virtual void  WriteTrailer(Int_t wordsNumber, Short_t hwAddress); 
+  //this method is used to write the trailer
+
+  virtual void  WriteRCUTrailer(Int_t rcuId);
+  //this method is used to write the RCU trailer
+
+  enum { kMaxWords = 1024 };
+
+ protected:
+  void          ReverseAndWrite();
+  //this method reverse the altro data order and write the buffer to the file
+
+  AliAltroBufferV3(const AliAltroBufferV3& source);
+  AliAltroBufferV3& operator = (const AliAltroBufferV3& source);
+
+  UShort_t fArray[kMaxWords]; // Temporary array needed in reverting data order
+  Int_t    fN;                // Size of the temporary array
+
+  ClassDef(AliAltroBufferV3,0)  // Interface to the Altro format
+};
+
+#endif
index 7c34c34af1bd7da368bc57d03e221f47e9da3be8..c04e5764bedd3ba5bcb1e7404bb367027696a81c 100644 (file)
@@ -3,6 +3,7 @@
 set(SRCS
 AliBitPacking.cxx
 AliAltroBuffer.cxx
+AliAltroBufferV3.cxx
 )
 
 # fill list of header files from list of source files
index 86669939580a9e956aacb87e92a3b73181af9117..5ed5a350b7710bee298e1a544188712a705c4abd 100644 (file)
@@ -6,5 +6,6 @@
 
 #pragma link C++ class AliBitPacking+;
 #pragma link C++ class AliAltroBuffer+;
+#pragma link C++ class AliAltroBufferV3+;
 
 #endif
index aa751c972d2d2475cf399c6f0b090fdca13559d0..5bcfdd58e85d29ea34effbf9036d1cb26843ca62 100644 (file)
@@ -1,6 +1,6 @@
 #-*- Mode: Makefile -*-
 
-SRCS:=  AliBitPacking.cxx AliAltroBuffer.cxx
+SRCS:=  AliBitPacking.cxx AliAltroBuffer.cxx AliAltroBufferV3.cxx
 
 HDRS:= $(SRCS:.cxx=.h)
 
@@ -16,7 +16,7 @@ ifdef DATE_ROOT
 EINCLUDE+= ${DATE_COMMON_DEFS}
 endif
 
-EXPORT:= AliAltroBuffer.h AliBitPacking.h
+EXPORT:= AliAltroBuffer.h AliAltroBufferV3.h AliBitPacking.h
 
 ifeq (win32gcc,$(ALICE_TARGET))
 PACKSOFLAGS:= $(SOFLAGS) -L$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET) \