]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliRawReaderDate.cxx
add support for TCastorFile (use CASTOR over rootd) and use
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDate.cxx
CommitLineData
16048fcf 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16///////////////////////////////////////////////////////////////////////////////
17//
18// This is a class for reading a raw data from a date event and providing
19// information about digits
20//
21///////////////////////////////////////////////////////////////////////////////
22
23#include "AliRawReaderDate.h"
24#ifdef ALI_DATE
25#include "event.h"
26#endif
27
28ClassImp(AliRawReaderDate)
29
30
31AliRawReaderDate::AliRawReaderDate(
32#ifdef ALI_DATE
33 void* event
34#else
35 void* /* event */
36#endif
37)
38{
39// create an object to read digits from the given date event
40
41#ifdef ALI_DATE
42 fEvent = (eventHeaderStruct*) event;
43 fSubEvent = NULL;
44 fPosition = fEnd = NULL;
45#else
46 Fatal("AliRawReaderDate", "this class was compiled without DATE");
47#endif
48}
49
50AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) :
51 AliRawReader(rawReader)
52{
53// copy constructor
54
55 fEvent = rawReader.fEvent;
56 fSubEvent = rawReader.fSubEvent;
57 fPosition = rawReader.fPosition;
58 fEnd = rawReader.fEnd;
59}
60
61AliRawReaderDate& AliRawReaderDate::operator = (const AliRawReaderDate&
62 rawReader)
63{
64// assignment operator
65
66 this->~AliRawReaderDate();
67 new(this) AliRawReaderDate(rawReader);
68 return *this;
69}
70
71
72UInt_t AliRawReaderDate::GetType() const
73{
74// get the type from the event header
75
76#ifdef ALI_DATE
77 if (!fEvent) return 0;
78 return fEvent->eventType;
79#else
80 return 0;
81#endif
82}
83
84UInt_t AliRawReaderDate::GetRunNumber() const
85{
86// get the run number from the event header
87
88#ifdef ALI_DATE
89 if (!fEvent) return 0;
90 return fEvent->eventRunNb;
91#else
92 return 0;
93#endif
94}
95
96const UInt_t* AliRawReaderDate::GetEventId() const
97{
98// get the event id from the event header
99
100#ifdef ALI_DATE
101 if (!fEvent) return NULL;
102 return fEvent->eventId;
103#else
104 return NULL;
105#endif
106}
107
108const UInt_t* AliRawReaderDate::GetTriggerPattern() const
109{
110// get the trigger pattern from the event header
111
112#ifdef ALI_DATE
113 if (!fEvent) return NULL;
114 return fEvent->eventTriggerPattern;
115#else
116 return NULL;
117#endif
118}
119
120const UInt_t* AliRawReaderDate::GetDetectorPattern() const
121{
122// get the detector pattern from the event header
123
124#ifdef ALI_DATE
125 if (!fEvent) return NULL;
126 return fEvent->eventDetectorPattern;
127#else
128 return NULL;
129#endif
130}
131
132const UInt_t* AliRawReaderDate::GetAttributes() const
133{
134// get the type attributes from the event header
135
136#ifdef ALI_DATE
137 if (!fEvent) return NULL;
138 return fEvent->eventTypeAttribute;
139#else
140 return NULL;
141#endif
142}
143
144UInt_t AliRawReaderDate::GetGDCId() const
145{
146// get the GDC Id from the event header
147
148#ifdef ALI_DATE
149 if (!fEvent) return 0;
150 return fEvent->eventGdcId;
151#else
152 return 0;
153#endif
154}
155
156
157Bool_t AliRawReaderDate::ReadMiniHeader()
158{
159// read a mini header at the current position
160// returns kFALSE if the mini header could not be read
161
162#ifdef ALI_DATE
163 if (!fEvent) return kFALSE;
164 do {
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
168 if (fSubEvent) {
169 fSubEvent = (eventHeaderStruct*) (((UChar_t*)fSubEvent) +
170 fSubEvent->eventSize);
171 } else {
172 if (fEvent->eventSize <= fEvent->eventHeadSize) return kFALSE; // no sub events
173 fSubEvent = (eventHeaderStruct*) (((UChar_t*)fEvent) +
174 fEvent->eventHeadSize);
175 }
176 fCount = 0;
177 fPosition = ((UChar_t*)fSubEvent) + fSubEvent->eventHeadSize +
178 sizeof(equipmentHeaderStruct);
179 fEnd = ((UChar_t*)fSubEvent) + fSubEvent->eventSize;
180 }
181 if (fPosition >= fEnd) continue; // no data left in the payload
182 if (fPosition + sizeof(AliMiniHeader) > fEnd) {
183 Error("ReadMiniHeader", "could not read data!");
184 return kFALSE;
185 }
186 fMiniHeader = (AliMiniHeader*) fPosition;
187 fPosition += sizeof(AliMiniHeader);
188 CheckMiniHeader();
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;
193 }
194 } while (!IsSelected());
195 return kTRUE;
196#else
197 return kFALSE;
198#endif
199}
200
201Bool_t AliRawReaderDate::ReadNextData(UChar_t*& data)
202{
203// reads the next payload at the current position
204// returns kFALSE if the data could not be read
205
206 while (fCount == 0) {
207 if (!ReadMiniHeader()) return kFALSE;
208 }
209 data = fPosition;
210 fPosition += fCount;
211 fCount = 0;
212 return kTRUE;
213}
214
215Bool_t AliRawReaderDate::ReadNext(UChar_t* data, Int_t size)
216{
217// reads the next block of data at the current position
218// returns kFALSE if the data could not be read
219
220 if (fPosition + size > fEnd) {
221 Error("ReadNext", "could not read data!");
222 return kFALSE;
223 }
224 memcpy(data, fPosition, size);
225 fPosition += size;
226 fCount -= size;
227 return kTRUE;
228}
229
230
231Bool_t AliRawReaderDate::Reset()
232{
233// reset the current position to the beginning of the event
234
235#ifdef ALI_DATE
236 fSubEvent = NULL;
237#endif
238 fCount = 0;
239 fPosition = fEnd = NULL;
240 return kTRUE;
241}