]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDrawData.cxx
Introduction of raw stream base class
[u/mrichter/AliRoot.git] / TRD / AliTRDrawData.cxx
index 03186a2bd3d30dff8ba95d640335ffa433f133cd..16e1a7b6d5b5d1096deb6332caf34058ba73f997 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-//#include <Riostream.h>
-
 #include <TMath.h>
 #include "TClass.h"
 
 #include "AliDAQ.h"
-#include "AliRawDataHeader.h"
+#include "AliRawDataHeaderSim.h"
 #include "AliRawReader.h"
 #include "AliLog.h"
 #include "AliFstream.h"
@@ -36,6 +34,8 @@
 #include "AliTRDdigitsManager.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDdataArrayI.h"
+#include "AliTRDdataArrayS.h"
+#include "AliTRDrawStreamBase.h"
 #include "AliTRDRawStream.h"
 #include "AliTRDRawStreamV2.h"
 #include "AliTRDcalibDB.h"
@@ -163,7 +163,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
     AliFstream* of = new AliFstream(name);
 
     // Write a dummy data header
-    AliRawDataHeader  header;  // the event header
+    AliRawDataHeaderSim  header;  // the event header
     UInt_t hpos = of->Tellp();
     of->WriteBuffer((char *) (& header), sizeof(header));
 
@@ -191,25 +191,38 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
         Int_t iDet = fGeo->GetDetector(plan,cham,sect);
 
         // Get the digits array
-        AliTRDdataArrayI *digits = digitsManager->GetDigits(iDet);
-        digits->Expand();
+        AliTRDdataArrayS *digits = (AliTRDdataArrayS *) digitsManager->GetDigits(iDet);
+        if (digits->HasData()) {
+
+          digits->Expand();
 
-        Int_t hcwords = 0;
-       Int_t rv = fFee->GetRAWversion();
+          Int_t hcwords = 0;
+         Int_t rv = fFee->GetRAWversion();
 
-        // Process A side of the chamber
-       if ( rv >= 1 && rv <= 2 ) hcwords = ProduceHcDataV1andV2(digits,0,iDet,hcBuffer,kMaxHcWords);
-       if ( rv == 3 )            hcwords = ProduceHcDataV3     (digits,0,iDet,hcBuffer,kMaxHcWords);
+          // Process A side of the chamber
+         if ( rv >= 1 && rv <= 2 ) {
+            hcwords = ProduceHcDataV1andV2(digits,0,iDet,hcBuffer,kMaxHcWords);
+         }
+         if ( rv == 3 ) { 
+            hcwords = ProduceHcDataV3     (digits,0,iDet,hcBuffer,kMaxHcWords);
+         }
 
-        of->WriteBuffer((char *) hcBuffer, hcwords*4);
-        npayloadbyte += hcwords*4;
+          of->WriteBuffer((char *) hcBuffer, hcwords*4);
+          npayloadbyte += hcwords*4;
 
-        // Process B side of the chamber
-       if ( rv >= 1 && rv <= 2 ) hcwords = ProduceHcDataV1andV2(digits,1,iDet,hcBuffer,kMaxHcWords);
-       if ( rv >= 3 )            hcwords = ProduceHcDataV3     (digits,1,iDet,hcBuffer,kMaxHcWords);
+          // Process B side of the chamber
+         if ( rv >= 1 && rv <= 2 ) {
+            hcwords = ProduceHcDataV1andV2(digits,1,iDet,hcBuffer,kMaxHcWords);
+         }
+         if ( rv >= 3 ) {
+            hcwords = ProduceHcDataV3     (digits,1,iDet,hcBuffer,kMaxHcWords);
+         }
+
+          of->WriteBuffer((char *) hcBuffer, hcwords*4);
+          npayloadbyte += hcwords*4;
+
+       }
 
-        of->WriteBuffer((char *) hcBuffer, hcwords*4);
-        npayloadbyte += hcwords*4;
       }
     }
 
@@ -228,7 +241,7 @@ Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDdataArrayI *digits, Int_t side
+Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDdataArrayS *digits, Int_t side
                                         , Int_t det, UInt_t *buf, Int_t maxSize)
 {
   //
@@ -413,7 +426,7 @@ Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDdataArrayI *digits, Int_t side
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDrawData::ProduceHcDataV3(AliTRDdataArrayI *digits, Int_t side
+Int_t AliTRDrawData::ProduceHcDataV3(AliTRDdataArrayS *digits, Int_t side
                                   , Int_t det, UInt_t *buf, Int_t maxSize)
 {
   //
@@ -558,7 +571,61 @@ AliTRDdigitsManager *AliTRDrawData::Raw2Digits(AliRawReader *rawReader)
   // Vx of the raw data reading
   //
 
-  AliTRDdataArrayI *digits = 0;
+  AliTRDdataArrayS *digits = 0;
+  AliTRDdataArrayI *track0 = 0;
+  AliTRDdataArrayI *track1 = 0;
+  AliTRDdataArrayI *track2 = 0; 
+
+  //AliTRDSignalIndex *indexes = 0;
+  // Create the digits manager
+  AliTRDdigitsManager* digitsManager = new AliTRDdigitsManager();
+  digitsManager->CreateArrays();
+
+  //AliTRDRawStream input(rawReader);
+  //   AliTRDRawStreamV2 input(rawReader);
+  //   input.SetRawVersion( fFee->GetRAWversion() );
+  //   input.Init();
+
+  AliTRDrawStreamBase *pinput = AliTRDrawStreamBase::GetRawStream(rawReader);
+  AliTRDrawStreamBase &input = *pinput;
+
+  AliInfo(Form("Stream version: %s", input.IsA()->GetName()));
+
+  // Loop through the digits
+  Int_t det    = 0;
+
+  while (det >= 0)
+    {
+      det = input.NextChamber(digitsManager);
+      if (det >= 0)
+       {
+         // get...
+         digits = (AliTRDdataArrayS *) digitsManager->GetDigits(det);
+         track0 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,0);
+         track1 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,1);
+         track2 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,2);
+         // and compress
+         if (digits) digits->Compress(1,0);
+         if (track0) track0->Compress(1,0);
+         if (track1) track1->Compress(1,0);
+         if (track2) track2->Compress(1,0);
+       }
+    }
+
+  delete pinput;
+  pinput = NULL;
+
+  return digitsManager;
+}
+
+//_____________________________________________________________________________
+AliTRDdigitsManager *AliTRDrawData::Raw2DigitsOLD(AliRawReader *rawReader)
+{
+  //
+  // Vx of the raw data reading
+  //
+
+  AliTRDdataArrayS *digits = 0;
   AliTRDdataArrayI *track0 = 0;
   AliTRDdataArrayI *track1 = 0;
   AliTRDdataArrayI *track2 = 0; 
@@ -593,10 +660,10 @@ AliTRDdigitsManager *AliTRDrawData::Raw2Digits(AliRawReader *rawReader)
          if (track2) track2->Compress(1,0);
        
          // Add a container for the digits of this detector
-         digits = digitsManager->GetDigits(det);
-         track0 = digitsManager->GetDictionary(det,0);
-         track1 = digitsManager->GetDictionary(det,1);
-         track2 = digitsManager->GetDictionary(det,2);
+         digits = (AliTRDdataArrayS *) digitsManager->GetDigits(det);
+         track0 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,0);
+         track1 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,1);
+         track2 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,2);
 
          // Allocate memory space for the digits buffer
          if (digits->GetNtime() == 0)