]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Completely Updated (Mario Sitta)
authormrodrigu <mrodrigu@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Feb 2008 11:13:24 +0000 (11:13 +0000)
committermrodrigu <mrodrigu@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Feb 2008 11:13:24 +0000 (11:13 +0000)
ACORDE/ACORDERaw2Digits_alien.C [new file with mode: 0644]
ACORDE/ACORDERaw2Digits_sim.C [new file with mode: 0644]
ACORDE/AliACORDERawStream.cxx [new file with mode: 0644]
ACORDE/AliACORDERawStream.h [new file with mode: 0644]

diff --git a/ACORDE/ACORDERaw2Digits_alien.C b/ACORDE/ACORDERaw2Digits_alien.C
new file mode 100644 (file)
index 0000000..f3433bb
--- /dev/null
@@ -0,0 +1,43 @@
+//_____________________________________________________//
+//                                                     //
+//    This macro reads ACORDE DDL Raw Data and          //
+//    converts it into Digits                          //
+//                                                     //
+//____________________________________________________ //
+
+
+void ACORDERaw2Digits(Int_t nEvents = 1, char* fileName = "alien:///alice/data/2008/LHC08a_ACORDE/000016788/raw/08000016788014.20.root")
+{
+  // Reads DDL data from fileName
+
+  TStopwatch timer;
+  timer.Start();
+
+  TGrid::Connect("alien://");
+
+  AliRawReader* rawReader = 0x0;
+//  rawReader = new AliRawReaderFile(fileName); // DDL files
+  rawReader = new AliRawReaderRoot(fileName); // DDL files
+
+  AliACORDERawStream* rawStream  = new AliACORDERawStream(rawReader);    
+
+  for (Int_t i=0; i<nEvents; i++) {
+    printf("=========== EVENT  %d ===========\n",i);
+    if (!rawReader->NextEvent())
+      break;
+
+    rawStream->Reset();
+    if (!rawStream->Next())
+      break;
+    printf("Data size is %d\n",rawStream->DataSize());
+    for (Int_t j=0; j<4; j++)
+      printf(" %x",rawStream->GetWord(j));
+    printf("\n");
+  }
+
+  delete rawReader;
+  delete rawStream;
+
+  timer.Stop();
+  timer.Print();
+}
diff --git a/ACORDE/ACORDERaw2Digits_sim.C b/ACORDE/ACORDERaw2Digits_sim.C
new file mode 100644 (file)
index 0000000..d9563e3
--- /dev/null
@@ -0,0 +1,73 @@
+//_____________________________________________________//
+//                                                     //
+//    This macro reads ACORDE DDL Raw Data and          //
+//    converts it into Digits                          //
+//                                                     //
+//____________________________________________________ //
+
+
+void ACORDERaw2Digits(Int_t nEvents = 1, char* fileName = "rawdata.root")
+{
+  // Reads DDL data from fileName
+
+  TStopwatch timer;
+  timer.Start();
+
+// Creates a TreeD to dump Digits
+
+  AliRunLoader* rl = AliRunLoader::Open("galice.root");    
+
+  AliACORDELoader* loader = (AliACORDELoader*) rl->GetLoader("ACORDELoader");
+  
+  if(!loader) {
+    AliError("no ACORDE loader found");
+    return kFALSE; }
+
+  TTree* treeD  = loader->TreeD();
+  if(!treeD) {
+      loader->MakeTree("D");
+      treeD = loader->TreeD(); }
+        
+  AliACORDEdigit  digit;
+  AliACORDEdigit* pdigit = &digit;
+  const Int_t kBufferSize = 4000;
+   
+  treeD->Branch("ACORDE", "AliACORDEdigit",  &pdigit, kBufferSize);
+
+  AliRawReader* rawReader = 0x0;
+//  rawReader = new AliRawReaderFile(fileName); // DDL files
+  rawReader = new AliRawReaderRoot(fileName); // DDL files
+
+  AliACORDERawStream* rawStream  = new AliACORDERawStream(rawReader);    
+
+  for (Int_t i=0; i<nEvents; i++) {
+    printf("=========== EVENT  %d ===========\n",i);
+    if (!rawReader->NextEvent())
+      break;
+
+    rawStream->Reset();
+    if (!rawStream->Next())
+      break;
+    printf("Data size is %d\n",rawStream->DataSize());
+  /*  
+  for(Int_t i=0; i<64; i++) {
+      new(pdigit) AliACORDEdigit(i, (Int_t)rawStream->GetADC(i), (Int_t)rawStream->GetTime(i)); 
+      treeD->Fill();
+  }
+  */ 
+// Checks if everything is OK by printing results 
+
+//   for(int i=0;i<64;i++) {
+//     printf("Channel %d : %d %d \n",i,rawStream->GetADC(i),rawStream->GetTime(i)); }
+//   treeD->Print(); printf(" \n"); 
+  }
+
+  loader->WriteDigits("OVERWRITE");
+  loader->UnloadDigits();      
+       
+  delete rawReader;
+  delete rawStream;
+
+  timer.Stop();
+  timer.Print();
+}
diff --git a/ACORDE/AliACORDERawStream.cxx b/ACORDE/AliACORDERawStream.cxx
new file mode 100644 (file)
index 0000000..dbee66a
--- /dev/null
@@ -0,0 +1,181 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Reads ACORDE DDL raw data from raw data stream                           //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliACORDERawStream.h"
+#include "AliRawReader.h"
+#include "AliLog.h"
+#include "AliDAQ.h"
+
+ClassImp(AliACORDERawStream)
+
+//_____________________________________________________________________________
+AliACORDERawStream::AliACORDERawStream(AliRawReader* rawReader) :
+  fRawReader(rawReader),
+  fPosition(-1),
+  fData(NULL),
+  fDataSize(0)
+{
+  //
+  // Create an object to read ACORDE raw data
+  //
+  // Created:      04 Feb 2008  Mario Sitta
+  //
+
+  // Select the raw data corresponding to the ACORDE detector id
+//  fRawReader->Reset();
+  AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("ACORDE")));
+  fRawReader->Select("ACORDE");
+
+}
+
+//_____________________________________________________________________________
+AliACORDERawStream::~AliACORDERawStream()
+{
+  // Default destructor
+}
+
+//_____________________________________________________________________________
+void AliACORDERawStream::Reset()
+{
+  //
+  // Reset the raw stream parameters
+  //
+  // Input:
+  //
+  // Output:
+  //
+  // Created:      04 Feb 2008  Mario Sitta
+  //
+
+  fPosition = -1;
+  fData = NULL;
+
+  if (fRawReader) fRawReader->Reset();
+}
+
+//_____________________________________________________________________________
+Bool_t AliACORDERawStream::Next()
+{
+  //
+  // Read next digit from the ACORDE raw data stream;
+  // return kFALSE in case of error or no digits left
+  //
+  // Input:
+  //
+  // Output:
+  //
+  // Created:      04 Feb 2008  Mario Sitta
+  //
+
+  if (fPosition >= 0) return kFALSE;
+
+  if (!fRawReader->ReadNextData(fData)) return kFALSE;
+  if (fRawReader->GetDataSize() == 0) return kFALSE;
+
+  fDataSize = fRawReader->GetDataSize();
+  if (fDataSize != 16) {
+    fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 5488",fDataSize));
+    AliWarning(Form("Wrong ACORDE raw data size: %d, expected 5488 bytes!",fDataSize));
+    return kFALSE;
+  }
+
+  fPosition = 0;
+
+  for (Int_t i=0; i<4; i++)
+    fWord[i] = GetNextWord();
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+UInt_t AliACORDERawStream::GetWord(Int_t index) const
+{
+  //
+  // Returns the ``index'' word from ACORDE raw data.
+  //
+  // Input:
+  //         index : the index of the requested word
+  // Output:
+  //         word  : the 32 bit ``index'' word
+  //
+  // Created:      12 Feb 2008  Mario Sitta
+  //
+
+  if (index < 0 || index > 3) {
+    AliWarning(Form("Wrong word index %d, returning 0",index));
+    return 0;
+  } else {
+    return fWord[index];
+  }
+  
+}
+
+//_____________________________________________________________________________
+UInt_t AliACORDERawStream::GetNextWord()
+{
+  //
+  // Returns the next 32 bit word inside the raw data payload.
+  // The method is supposed to be endian (platform) independent.
+  //
+  // Input:
+  //
+  // Output:
+  //         word : a 32 bit word containing the data
+  //
+  // Created:      04 Feb 2008  Mario Sitta
+  //
+
+  if (!fData || fPosition < 0)
+    AliFatal("Raw data payload buffer is not yet initialized !");
+
+  UInt_t word = 0;
+  word |= fData[fPosition++];
+  word |= fData[fPosition++] << 8;
+  word |= fData[fPosition++] << 16;
+  word |= fData[fPosition++] << 24;
+
+  return word;
+}
+
+//_____________________________________________________________________________
+UShort_t AliACORDERawStream::GetNextShort()
+{
+  //
+  // Returns the next 16 bit word inside the raw data payload.
+  // The method is supposed to be endian (platform) independent.
+  //
+  // Input:
+  //
+  // Output:
+  //         word : a 16 bit word containing the data
+  //
+  // Created:      04 Feb 2008  Mario Sitta
+  //
+
+  if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
+
+  UShort_t word = 0;
+  word |= fData[fPosition++];
+  word |= fData[fPosition++] << 8;
+
+  return word;
+}
+
diff --git a/ACORDE/AliACORDERawStream.h b/ACORDE/AliACORDERawStream.h
new file mode 100644 (file)
index 0000000..fb5a300
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef ALIACORDERAWSTREAM_H
+#define ALIACORDERAWSTREAM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliACORDERawStream.h 20210 2007-08-18 08:41:30Z hristov $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Reads ACORDE DDL raw data from raw data stream                           //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+
+class AliRawReader;
+
+class AliACORDERawStream : public TObject {
+
+ public:
+
+  AliACORDERawStream(AliRawReader*);
+  virtual ~AliACORDERawStream();
+//  AliACORDERawStream &operator=(const AliACORDERawStream &r);
+
+  virtual void    Reset();
+  virtual Bool_t  Next();
+
+  Int_t           DataSize() const { return fDataSize; }
+  UInt_t          GetWord(Int_t index) const;
+
+  enum EACORDERawStreamError {
+      kRawDataSizeErr = 1
+  };
+
+ private:
+
+  UInt_t          GetNextWord();
+  UShort_t        GetNextShort();
+
+
+  AliRawReader*   fRawReader;    // object for reading the raw data
+  Int_t           fPosition;     // current position in the raw-data payload
+  UChar_t*        fData;         // pointer to raw data payload
+
+  Int_t           fDataSize;     // data size
+
+  UInt_t          fWord[4];      // data vector
+
+  ClassDef(AliACORDERawStream,0) // class for reading ACORDE DDL raw data
+
+};
+
+typedef AliACORDERawStream AliCRTRawStream; // for backward compatibility
+
+#endif