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 a class for reading a raw data from a date event and providing
19 // information about digits
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "AliRawReaderDate.h"
28 ClassImp(AliRawReaderDate)
31 AliRawReaderDate::AliRawReaderDate(
39 // create an object to read digits from the given date event
42 fEvent = (eventHeaderStruct*) event;
44 fPosition = fEnd = NULL;
46 Fatal("AliRawReaderDate", "this class was compiled without DATE");
50 AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) :
51 AliRawReader(rawReader)
55 fEvent = rawReader.fEvent;
56 fSubEvent = rawReader.fSubEvent;
57 fPosition = rawReader.fPosition;
58 fEnd = rawReader.fEnd;
61 AliRawReaderDate& AliRawReaderDate::operator = (const AliRawReaderDate&
64 // assignment operator
66 this->~AliRawReaderDate();
67 new(this) AliRawReaderDate(rawReader);
72 UInt_t AliRawReaderDate::GetType() const
74 // get the type from the event header
77 if (!fEvent) return 0;
78 return fEvent->eventType;
84 UInt_t AliRawReaderDate::GetRunNumber() const
86 // get the run number from the event header
89 if (!fEvent) return 0;
90 return fEvent->eventRunNb;
96 const UInt_t* AliRawReaderDate::GetEventId() const
98 // get the event id from the event header
101 if (!fEvent) return NULL;
102 return fEvent->eventId;
108 const UInt_t* AliRawReaderDate::GetTriggerPattern() const
110 // get the trigger pattern from the event header
113 if (!fEvent) return NULL;
114 return fEvent->eventTriggerPattern;
120 const UInt_t* AliRawReaderDate::GetDetectorPattern() const
122 // get the detector pattern from the event header
125 if (!fEvent) return NULL;
126 return fEvent->eventDetectorPattern;
132 const UInt_t* AliRawReaderDate::GetAttributes() const
134 // get the type attributes from the event header
137 if (!fEvent) return NULL;
138 return fEvent->eventTypeAttribute;
144 UInt_t AliRawReaderDate::GetGDCId() const
146 // get the GDC Id from the event header
149 if (!fEvent) return 0;
150 return fEvent->eventGdcId;
157 Bool_t AliRawReaderDate::ReadMiniHeader()
159 // read a mini header at the current position
160 // returns kFALSE if the mini header could not be read
163 if (!fEvent) return kFALSE;
165 if (fCount > 0) fPosition += fCount; // skip payload if event was not selected
166 if (!fSubEvent || (fPosition >= fEnd)) { // new sub event
167 if (fPosition >= ((UChar_t*)fEvent)+fEvent->eventSize) return kFALSE; // end of data
169 fSubEvent = (eventHeaderStruct*) (((UChar_t*)fSubEvent) +
170 fSubEvent->eventSize);
172 if (fEvent->eventSize <= fEvent->eventHeadSize) return kFALSE; // no sub events
173 fSubEvent = (eventHeaderStruct*) (((UChar_t*)fEvent) +
174 fEvent->eventHeadSize);
177 fPosition = ((UChar_t*)fSubEvent) + fSubEvent->eventHeadSize +
178 sizeof(equipmentHeaderStruct);
179 fEnd = ((UChar_t*)fSubEvent) + fSubEvent->eventSize;
181 if (fPosition >= fEnd) continue; // no data left in the payload
182 if (fPosition + sizeof(AliMiniHeader) > fEnd) {
183 Error("ReadMiniHeader", "could not read data!");
186 fMiniHeader = (AliMiniHeader*) fPosition;
187 fPosition += sizeof(AliMiniHeader);
189 fCount = fMiniHeader->fSize;
190 if (fPosition + fCount > fEnd) { // check data size in mini header and sub event
191 Error("ReadMiniHeader", "size in mini header exceeds event size!");
192 fMiniHeader->fSize = fCount = fEnd - fPosition;
194 } while (!IsSelected());
201 Bool_t AliRawReaderDate::ReadNextData(UChar_t*& data)
203 // reads the next payload at the current position
204 // returns kFALSE if the data could not be read
206 while (fCount == 0) {
207 if (!ReadMiniHeader()) return kFALSE;
215 Bool_t AliRawReaderDate::ReadNext(UChar_t* data, Int_t size)
217 // reads the next block of data at the current position
218 // returns kFALSE if the data could not be read
220 if (fPosition + size > fEnd) {
221 Error("ReadNext", "could not read data!");
224 memcpy(data, fPosition, size);
231 Bool_t AliRawReaderDate::Reset()
233 // reset the current position to the beginning of the event
239 fPosition = fEnd = NULL;