-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * *\r
- * Author: The ALICE Off-line Project. *\r
- * Contributors are mentioned in the code where appropriate. *\r
- * *\r
- * Permission to use, copy, modify and distribute this software and its *\r
- * documentation strictly for non-commercial purposes is hereby granted *\r
- * without fee, provided that the above copyright notice appears in all *\r
- * copies and that both the copyright notice and this permission notice *\r
- * appear in the supporting documentation. The authors make no claims *\r
- * about the suitability of this software for any purpose. It is *\r
- * provided "as is" without express or implied warranty. *\r
- **************************************************************************/\r
-\r
-///////////////////////////////////////////////////////////////////////////////\r
-// //\r
-// Reads ACORDE DDL raw data from raw data stream //\r
-// //\r
-///////////////////////////////////////////////////////////////////////////////\r
-\r
-#include "AliACORDERawStream.h"\r
-#include "AliRawReader.h"\r
-#include "AliLog.h"\r
-#include "AliDAQ.h"\r
-#include "AliRawReaderRoot.h"\r
-\r
-ClassImp(AliACORDERawStream)\r
-\r
-//_____________________________________________________________________________\r
-AliACORDERawStream::AliACORDERawStream(AliRawReader* rawReader) :\r
- fRawReader(rawReader),\r
- fPosition(-1),\r
- fData(NULL),\r
- fDataSize(0)\r
-{\r
- //\r
- // Create an object to read ACORDE raw data\r
- //\r
- // Created: 04 Feb 2008 Mario Sitta\r
- //\r
-\r
- fWord[0] = fWord[1] = fWord[2] = fWord[3] = 0;\r
-\r
- // Select the raw data corresponding to the ACORDE detector id\r
-// fRawReader->Reset();\r
- AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("ACORDE")));\r
- fRawReader->Select("ACORDE");\r
-\r
-}\r
-\r
-//_____________________________________________________________________________\r
-AliACORDERawStream::AliACORDERawStream(const AliACORDERawStream &r) :\r
- TObject(),\r
- fRawReader(r.fRawReader),\r
- fPosition(-1),\r
- fData(NULL),\r
- fDataSize(0)\r
-{\r
- // Simple copy constructor\r
- ((AliACORDERawStream &) r).Copy(*this);\r
-}\r
-\r
-//_____________________________________________________________________________\r
-AliACORDERawStream::~AliACORDERawStream()\r
-{\r
- // Default destructor\r
-}\r
-\r
-//_____________________________________________________________________________\r
-AliACORDERawStream &AliACORDERawStream::operator=(const AliACORDERawStream &r)\r
-{\r
- // Simple operator=\r
- if (this != &r) ((AliACORDERawStream &) r).Copy(*this);\r
- return *this;\r
-}\r
-\r
-//_____________________________________________________________________________\r
-void AliACORDERawStream::Reset()\r
-{\r
- //\r
- // Reset the raw stream parameters\r
- //\r
- // Input:\r
- //\r
- // Output:\r
- //\r
- // Created: 04 Feb 2008 Mario Sitta\r
- //\r
-\r
- fPosition = -1;\r
- fData = NULL;\r
-\r
- if (fRawReader) fRawReader->Reset();\r
-}\r
-\r
-//_____________________________________________________________________________\r
-Bool_t AliACORDERawStream::Next()\r
-{\r
- //\r
- // Read next digit from the ACORDE raw data stream;\r
- // return kFALSE in case of error or no digits left\r
- //\r
- // Input:\r
- //\r
- // Output:\r
- //\r
- // Created: 04 Feb 2008 Mario Sitta\r
- //\r
-\r
- if (fPosition >= 0) return kFALSE;\r
-\r
- if (!fRawReader->ReadNextData(fData)) return kFALSE;\r
- if (fRawReader->GetDataSize() == 0) return kFALSE;\r
-\r
- fDataSize = fRawReader->GetDataSize();\r
- if (fDataSize != 16) {\r
- fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 16",fDataSize));\r
- AliWarning(Form("Wrong ACORDE raw data size: %d, expected 16 bytes!",fDataSize));\r
- return kFALSE;\r
- }\r
-\r
- fPosition = 0;\r
-\r
- for (Int_t i=0; i<4; i++)\r
- fWord[i] = GetNextWord();\r
-\r
- return kTRUE;\r
-}\r
-\r
-//_____________________________________________________________________________\r
-UInt_t AliACORDERawStream::GetWord(Int_t index) const\r
-{\r
- //\r
- // Returns the ``index'' word from ACORDE raw data.\r
- //\r
- // Input:\r
- // index : the index of the requested word\r
- // Output:\r
- // word : the 32 bit ``index'' word\r
- //\r
- // Created: 12 Feb 2008 Mario Sitta\r
- //\r
-\r
- if (index < 0 || index > 3) {\r
- AliWarning(Form("Wrong word index %d, returning 0",index));\r
- return 0;\r
- } else {\r
- return fWord[index];\r
- }\r
- \r
-}\r
-\r
-//_____________________________________________________________________________\r
-UInt_t AliACORDERawStream::GetNextWord()\r
-{\r
- //\r
- // Returns the next 32 bit word inside the raw data payload.\r
- // The method is supposed to be endian (platform) independent.\r
- //\r
- // Input:\r
- //\r
- // Output:\r
- // word : a 32 bit word containing the data\r
- //\r
- // Created: 04 Feb 2008 Mario Sitta\r
- //\r
-\r
- if (!fData || fPosition < 0)\r
- AliFatal("Raw data payload buffer is not yet initialized !");\r
-\r
- UInt_t word = 0;\r
- word |= fData[fPosition++];\r
- word |= fData[fPosition++] << 8;\r
- word |= fData[fPosition++] << 16;\r
- word |= fData[fPosition++] << 24;\r
-\r
- return word;\r
-}\r
-\r
-//_____________________________________________________________________________\r
-\r
-Int_t AliACORDERawStream::GetNEvents(char* fileName) \r
-{\r
- // Returns the Total Number of Events recorded by ACORDE \r
- // Note: it may be a better way to do it !!\r
- // Input: fileName to Analyze\r
- // Output: Number of Total Events (fNEvents) in fileName\r
- // Created: 25 March 2008\r
- // Author: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>\r
- \r
- AliRawReader* rCount = new AliRawReaderRoot(fileName);\r
- Int_t DyM=0;\r
- Int_t fNEvents=0;\r
- while(DyM==0)\r
- {\r
- if (!rCount->NextEvent()) DyM=1;\r
- else fNEvents++;\r
- }\r
- delete rCount;\r
- return fNEvents;\r
-}\r
-\r
-//____________________________________________________________________________\r
+/**************************************************************************
+ * 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"
+#include "AliRawReaderRoot.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
+ //
+
+ fWord[0] = fWord[1] = fWord[2] = fWord[3] = 0;
+
+ // 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(const AliACORDERawStream &r) :
+ TObject(),
+ fRawReader(r.fRawReader),
+ fPosition(-1),
+ fData(NULL),
+ fDataSize(0)
+{
+ // Simple copy constructor
+ ((AliACORDERawStream &) r).Copy(*this);
+}
+
+//_____________________________________________________________________________
+AliACORDERawStream::~AliACORDERawStream()
+{
+ // Default destructor
+}
+
+//_____________________________________________________________________________
+AliACORDERawStream &AliACORDERawStream::operator=(const AliACORDERawStream &r)
+{
+ // Simple operator=
+ if (this != &r) ((AliACORDERawStream &) r).Copy(*this);
+ return *this;
+}
+
+//_____________________________________________________________________________
+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 != 16",fDataSize));
+ AliWarning(Form("Wrong ACORDE raw data size: %d, expected 16 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;
+}
+
+//_____________________________________________________________________________
+
+Int_t AliACORDERawStream::GetNEvents(char* fileName)
+{
+ // Returns the Total Number of Events recorded by ACORDE
+ // Note: it may be a better way to do it !!
+ // Input: fileName to Analyze
+ // Output: Number of Total Events (fNEvents) in fileName
+ // Created: 25 March 2008
+ // Author: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
+
+ AliRawReader* rCount = new AliRawReaderRoot(fileName);
+ Int_t DyM=0;
+ Int_t fNEvents=0;
+ while(DyM==0)
+ {
+ if (!rCount->NextEvent()) DyM=1;
+ else fNEvents++;
+ }
+ delete rCount;
+ return fNEvents;
+}
+
+//____________________________________________________________________________