]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/Ref/AliHLTTPCDDLRawReader.cxx
Added a Makefile with rules for component libraries conforming to the
[u/mrichter/AliRoot.git] / HLT / TPCLib / Ref / AliHLTTPCDDLRawReader.cxx
CommitLineData
78001a73 1// @(#) $Id$
2
3// Author: Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de>
4//*-- Copyright &copy ALICE HLT Group
5
6#include "AliHLTTPCRootTypes.h"
7#include "AliHLTTPCStandardIncludes.h"
8#include "AliHLTTPCLogging.h"
9
10#include "AliHLTTPCDDLRawReader.h"
11
12/**************************************************************************
13 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
14 * *
15 * Author: The ALICE Off-line Project. *
16 * Contributors are mentioned in the code where appropriate. *
17 * *
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 **************************************************************************/
26
27/** \class AliHLTTPCDDLRawReader
28<pre>
29//_____________________________________________________________
30// AliHLTTPCDDLRawReader (taken from the offline AliROOT code,
31// original authors: D.Favretto and A.K.Mohanty)
32//
33// This is the base class for reading ddl raw data
34// and providing information about digits
35</pre>
36*/
37
38ClassImp(AliHLTTPCDDLRawReader)
39
40AliHLTTPCDDLRawReader::AliHLTTPCDDLRawReader()
41{
42 fMiniHeader = NULL;
43 fCount = 0;
44 fSelectDetectorID = -1;
45 fSelectMinDDLID = -1;
46 fSelectMaxDDLID = -1;
47}
48
49AliHLTTPCDDLRawReader::~AliHLTTPCDDLRawReader()
50{
51}
52
53void AliHLTTPCDDLRawReader::Select(Int_t detectorID, Int_t minDDLID, Int_t maxDDLID)
54{
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.
58
59 fSelectDetectorID = detectorID;
60 fSelectMinDDLID = minDDLID;
61 fSelectMaxDDLID = maxDDLID;
62}
63
64Bool_t AliHLTTPCDDLRawReader::IsSelected()
65{
66 // apply the selection (if any)
67
68 if (fSelectDetectorID >= 0) {
69 if (fMiniHeader->fDetectorID != fSelectDetectorID) return kFALSE;
70 if ((fSelectMinDDLID >= 0) && (fMiniHeader->fDDLID < fSelectMinDDLID))
71 return kFALSE;
72 if ((fSelectMaxDDLID >= 0) && (fMiniHeader->fDDLID >= fSelectMaxDDLID))
73 return kFALSE;
74 }
75 return kTRUE;
76}
77
78Bool_t AliHLTTPCDDLRawReader::CheckMiniHeader()
79{
80 // check the magic number of the mini header
81
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;
87 return kFALSE;
88 }
89 return kTRUE;
90}
91
92Bool_t AliHLTTPCDDLRawReader::ReadNextInt(UInt_t& data)
93{
94 // reads the next 4 bytes at the current position
95 // returns kFALSE if the data could not be read
96
97 while (fCount == 0) {
98 if (!ReadMiniHeader()) return kFALSE;
99 }
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;
103 return kFALSE;
104 }
105 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
106 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextInt","Data")
107 <<"Could not read data."<<ENDLOG;
108 return kFALSE;
109 }
110 return kTRUE;
111}
112
113Bool_t AliHLTTPCDDLRawReader::ReadNextShort(UShort_t& data)
114{
115 // reads the next 2 bytes at the current position
116 // returns kFALSE if the data could not be read
117
118 while (fCount == 0) {
119 if (!ReadMiniHeader()) return kFALSE;
120 }
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;
124 return kFALSE;
125 }
126 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
127 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextShort","Data")
128 <<"Could not read data."<<ENDLOG;
129 return kFALSE;
130 }
131 return kTRUE;
132}
133
134Bool_t AliHLTTPCDDLRawReader::ReadNextChar(UChar_t& data)
135{
136 // reads the next 1 byte at the current stream position
137 // returns kFALSE if the data could not be read
138
139 while (fCount == 0) {
140 if (!ReadMiniHeader()) return kFALSE;
141 }
142 if (!ReadNext((UChar_t*) &data, sizeof(data))) {
143 LOG(AliHLTTPCLog::kError,"AliHLTTPCDDLRawReader::ReadNextChar","Data")
144 <<"Could not read data."<<ENDLOG;
145 return kFALSE;
146 }
147 return kTRUE;
148}
149