3 // Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliHLTTPCRootTypes.h"
7 #include "AliHLTTPCStandardIncludes.h"
8 #include "AliHLTTPCLogging.h"
10 #include "AliHLTTPCDDLRawReader.h"
12 /**************************************************************************
13 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
15 * Author: The ALICE Off-line Project. *
16 * Contributors are mentioned in the code where appropriate. *
18 * Permission to use, copy, modify and distribute this software and its *
19 * documentation strictly for non-commercial purposes is hereby granted *
20 * without fee, provided that the above copyright notice appears in all *
21 * copies and that both the copyright notice and this permission notice *
22 * appear in the supporting documentation. The authors make no claims *
23 * about the suitability of this software for any purpose. It is *
24 * provided "as is" without express or implied warranty. *
25 **************************************************************************/
27 /** \class AliHLTTPCDDLRawReader
29 //_____________________________________________________________
30 // AliHLTTPCDDLRawReader (taken from the offline AliROOT code,
31 // original authors: D.Favretto and A.K.Mohanty)
33 // This is the base class for reading ddl raw data
34 // and providing information about digits
38 ClassImp(AliHLTTPCDDLRawReader)
40 AliHLTTPCDDLRawReader::AliHLTTPCDDLRawReader()
44 fSelectDetectorID = -1;
49 AliHLTTPCDDLRawReader::~AliHLTTPCDDLRawReader()
53 void AliHLTTPCDDLRawReader::Select(Int_t detectorID, Int_t minDDLID, Int_t maxDDLID)
55 // read only data of the detector with the given ID and in the given
56 // range of DDLs (minDDLID <= DDLID < maxDDLID).
57 // no selection is applied if a value < 0 is used.
59 fSelectDetectorID = detectorID;
60 fSelectMinDDLID = minDDLID;
61 fSelectMaxDDLID = maxDDLID;
64 Bool_t AliHLTTPCDDLRawReader::IsSelected()
66 // apply the selection (if any)
68 if (fSelectDetectorID >= 0) {
69 if (fMiniHeader->fDetectorID != fSelectDetectorID) return kFALSE;
70 if ((fSelectMinDDLID >= 0) && (fMiniHeader->fDDLID < fSelectMinDDLID))
72 if ((fSelectMaxDDLID >= 0) && (fMiniHeader->fDDLID >= fSelectMaxDDLID))
78 Bool_t AliHLTTPCDDLRawReader::CheckMiniHeader()
80 // check the magic number of the mini header
82 if ((fMiniHeader->fMagicWord[2] != 0x12) ||
83 (fMiniHeader->fMagicWord[1] != 0x34) ||
84 (fMiniHeader->fMagicWord[0] != 0x56)) {
85 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::CheckMiniHeader","MH")
86 <<"DDL mini header has wrong magic word!"<<ENDLOG;
92 Bool_t AliHLTTPCDDLRawReader::ReadNextInt(UInt_t& data)
94 // reads the next 4 bytes at the current position
95 // returns kFALSE if the data could not be read
98 if (!ReadMiniHeader()) return kFALSE;
100 if (fCount < (Int_t) sizeof(data)) {
101 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextInt","Data")
102 <<AliHLTTPCLog::kDec<<"Too few data left ("<<fCount<<") to read UInt_t!"<<ENDLOG;
105 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
106 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextInt","Data")
107 <<"Could not read data."<<ENDLOG;
113 Bool_t AliHLTTPCDDLRawReader::ReadNextShort(UShort_t& data)
115 // reads the next 2 bytes at the current position
116 // returns kFALSE if the data could not be read
118 while (fCount == 0) {
119 if (!ReadMiniHeader()) return kFALSE;
121 if (fCount < (Int_t) sizeof(data)) {
122 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextShort","Data")
123 <<AliHLTTPCLog::kDec<<"Too few data left ("<<fCount<<") to read UShort_t!"<<ENDLOG;
126 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
127 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextShort","Data")
128 <<"Could not read data."<<ENDLOG;
134 Bool_t AliHLTTPCDDLRawReader::ReadNextChar(UChar_t& data)
136 // reads the next 1 byte at the current stream position
137 // returns kFALSE if the data could not be read
139 while (fCount == 0) {
140 if (!ReadMiniHeader()) return kFALSE;
142 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
143 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextChar","Data")
144 <<"Could not read data."<<ENDLOG;