3 // Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliL3RootTypes.h"
7 #include "AliL3StandardIncludes.h"
8 #include "AliL3Logging.h"
10 #include "AliL3DDLRawReader.h"
16 /**************************************************************************
17 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
19 * Author: The ALICE Off-line Project. *
20 * Contributors are mentioned in the code where appropriate. *
22 * Permission to use, copy, modify and distribute this software and its *
23 * documentation strictly for non-commercial purposes is hereby granted *
24 * without fee, provided that the above copyright notice appears in all *
25 * copies and that both the copyright notice and this permission notice *
26 * appear in the supporting documentation. The authors make no claims *
27 * about the suitability of this software for any purpose. It is *
28 * provided "as is" without express or implied warranty. *
29 **************************************************************************/
31 /** \class AliL3DDLRawReader
33 //_____________________________________________________________
34 // AliL3DDLRawReader (taken from the offline AliROOT code,
35 // original authors: D.Favretto and A.K.Mohanty)
37 // This is the base class for reading ddl raw data
38 // and providing information about digits
42 ClassImp(AliL3DDLRawReader)
44 AliL3DDLRawReader::AliL3DDLRawReader()
48 fSelectDetectorID = -1;
53 AliL3DDLRawReader::~AliL3DDLRawReader()
57 void AliL3DDLRawReader::Select(Int_t detectorID, Int_t minDDLID, Int_t maxDDLID)
59 // read only data of the detector with the given ID and in the given
60 // range of DDLs (minDDLID <= DDLID < maxDDLID).
61 // no selection is applied if a value < 0 is used.
63 fSelectDetectorID = detectorID;
64 fSelectMinDDLID = minDDLID;
65 fSelectMaxDDLID = maxDDLID;
68 Bool_t AliL3DDLRawReader::IsSelected() const
70 // apply the selection (if any)
72 if (fSelectDetectorID >= 0) {
73 if (fMiniHeader->fDetectorID != fSelectDetectorID) return kFALSE;
74 if ((fSelectMinDDLID >= 0) && (fMiniHeader->fDDLID < fSelectMinDDLID))
76 if ((fSelectMaxDDLID >= 0) && (fMiniHeader->fDDLID >= fSelectMaxDDLID))
82 Bool_t AliL3DDLRawReader::CheckMiniHeader() const
84 // check the magic number of the mini header
86 if ((fMiniHeader->fMagicWord[2] != 0x12) ||
87 (fMiniHeader->fMagicWord[1] != 0x34) ||
88 (fMiniHeader->fMagicWord[0] != 0x56)) {
89 LOG(AliL3Log::kError,"AliL3DDLRawReader::CheckMiniHeader","MH")
90 <<"DDL mini header has wrong magic word!"<<ENDLOG;
96 Bool_t AliL3DDLRawReader::ReadNextInt(UInt_t& data)
98 // reads the next 4 bytes at the current position
99 // returns kFALSE if the data could not be read
101 while (fCount == 0) {
102 if (!ReadMiniHeader()) return kFALSE;
104 if (fCount < (Int_t) sizeof(data)) {
105 LOG(AliL3Log::kError,"AliL3DDLRawReader::ReadNextInt","Data")
106 <<AliL3Log::kDec<<"Too few data left ("<<fCount<<") to read UInt_t!"<<ENDLOG;
109 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
110 LOG(AliL3Log::kError,"AliL3DDLRawReader::ReadNextInt","Data")
111 <<"Could not read data."<<ENDLOG;
117 Bool_t AliL3DDLRawReader::ReadNextShort(UShort_t& data)
119 // reads the next 2 bytes at the current position
120 // returns kFALSE if the data could not be read
122 while (fCount == 0) {
123 if (!ReadMiniHeader()) return kFALSE;
125 if (fCount < (Int_t) sizeof(data)) {
126 LOG(AliL3Log::kError,"AliL3DDLRawReader::ReadNextShort","Data")
127 <<AliL3Log::kDec<<"Too few data left ("<<fCount<<") to read UShort_t!"<<ENDLOG;
130 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
131 LOG(AliL3Log::kError,"AliL3DDLRawReader::ReadNextShort","Data")
132 <<"Could not read data."<<ENDLOG;
138 Bool_t AliL3DDLRawReader::ReadNextChar(UChar_t& data)
140 // reads the next 1 byte at the current stream position
141 // returns kFALSE if the data could not be read
143 while (fCount == 0) {
144 if (!ReadMiniHeader()) return kFALSE;
146 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
147 LOG(AliL3Log::kError,"AliL3DDLRawReader::ReadNextChar","Data")
148 <<"Could not read data."<<ENDLOG;