1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 // This is the base class for reading raw data and providing
19 // information about digits
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "AliRawReader.h"
26 ClassImp(AliRawReader)
29 AliRawReader::AliRawReader()
34 fSelectDetectorID = -1;
40 void AliRawReader::Select(Int_t detectorID, Int_t minDDLID, Int_t maxDDLID)
42 // read only data of the detector with the given ID and in the given
43 // range of DDLs (minDDLID <= DDLID < maxDDLID).
44 // no selection is applied if a value < 0 is used.
46 fSelectDetectorID = detectorID;
47 fSelectMinDDLID = minDDLID;
48 fSelectMaxDDLID = maxDDLID;
51 Bool_t AliRawReader::IsSelected()
53 // apply the selection (if any)
55 if (fSelectDetectorID >= 0) {
56 if (fMiniHeader->fDetectorID != fSelectDetectorID) return kFALSE;
57 if ((fSelectMinDDLID >= 0) && (fMiniHeader->fDDLID < fSelectMinDDLID))
59 if ((fSelectMaxDDLID >= 0) && (fMiniHeader->fDDLID >= fSelectMaxDDLID))
66 Bool_t AliRawReader::CheckMiniHeader()
68 // check the magic number of the mini header
70 if ((fMiniHeader->fMagicWord[2] != 0x12) ||
71 (fMiniHeader->fMagicWord[1] != 0x34) ||
72 (fMiniHeader->fMagicWord[0] != 0x56)) {
73 Error("CheckMiniHeader", "wrong magic word!");
79 Bool_t AliRawReader::ReadNextInt(UInt_t& data)
81 // reads the next 4 bytes at the current position
82 // returns kFALSE if the data could not be read
85 if (!ReadMiniHeader()) return kFALSE;
87 if (fCount < (Int_t) sizeof(data)) {
89 "too few data left (%d bytes) to read an UInt_t!", fCount);
92 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
93 Error("ReadNextInt", "could not read data!");
99 Bool_t AliRawReader::ReadNextShort(UShort_t& data)
101 // reads the next 2 bytes at the current position
102 // returns kFALSE if the data could not be read
104 while (fCount == 0) {
105 if (!ReadMiniHeader()) return kFALSE;
107 if (fCount < (Int_t) sizeof(data)) {
108 Error("ReadNextShort",
109 "too few data left (%d bytes) to read an UShort_t!", fCount);
112 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
113 Error("ReadNextShort", "could not read data!");
119 Bool_t AliRawReader::ReadNextChar(UChar_t& data)
121 // reads the next 1 byte at the current stream position
122 // returns kFALSE if the data could not be read
124 while (fCount == 0) {
125 if (!ReadMiniHeader()) return kFALSE;
127 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
128 Error("ReadNextChar", "could not read data!");