]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ACORDE/AliACORDERawStream.cxx
Load pythia libraries.
[u/mrichter/AliRoot.git] / ACORDE / AliACORDERawStream.cxx
CommitLineData
03e41177 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
16///////////////////////////////////////////////////////////////////////////////\r
17// //\r
18// Reads ACORDE DDL raw data from raw data stream //\r
19// //\r
20///////////////////////////////////////////////////////////////////////////////\r
21\r
22#include "AliACORDERawStream.h"\r
23#include "AliRawReader.h"\r
24#include "AliLog.h"\r
25#include "AliDAQ.h"\r
26\r
27ClassImp(AliACORDERawStream)\r
28\r
29//_____________________________________________________________________________\r
30AliACORDERawStream::AliACORDERawStream(AliRawReader* rawReader) :\r
31 fRawReader(rawReader),\r
32 fPosition(-1),\r
33 fData(NULL),\r
34 fDataSize(0)\r
35{\r
36 //\r
37 // Create an object to read ACORDE raw data\r
38 //\r
39 // Created: 04 Feb 2008 Mario Sitta\r
40 //\r
41\r
42 // Select the raw data corresponding to the ACORDE detector id\r
43// fRawReader->Reset();\r
44 AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("ACORDE")));\r
45 fRawReader->Select("ACORDE");\r
46\r
47}\r
48\r
49//_____________________________________________________________________________\r
50AliACORDERawStream::AliACORDERawStream(const AliACORDERawStream &r) :\r
51 TObject(),\r
52 fRawReader(r.fRawReader),\r
53 fPosition(-1),\r
54 fData(NULL),\r
55 fDataSize(0)\r
56{\r
57 // Simple copy constructor\r
58 ((AliACORDERawStream &) r).Copy(*this);\r
59}\r
60\r
61//_____________________________________________________________________________\r
62AliACORDERawStream::~AliACORDERawStream()\r
63{\r
64 // Default destructor\r
65}\r
66\r
67//_____________________________________________________________________________\r
68AliACORDERawStream &AliACORDERawStream::operator=(const AliACORDERawStream &r)\r
69{\r
70 // Simple operator=\r
71 if (this != &r) ((AliACORDERawStream &) r).Copy(*this);\r
72 return *this;\r
73}\r
74\r
75//_____________________________________________________________________________\r
76void AliACORDERawStream::Reset()\r
77{\r
78 //\r
79 // Reset the raw stream parameters\r
80 //\r
81 // Input:\r
82 //\r
83 // Output:\r
84 //\r
85 // Created: 04 Feb 2008 Mario Sitta\r
86 //\r
87\r
88 fPosition = -1;\r
89 fData = NULL;\r
90\r
91 if (fRawReader) fRawReader->Reset();\r
92}\r
93\r
94//_____________________________________________________________________________\r
95Bool_t AliACORDERawStream::Next()\r
96{\r
97 //\r
98 // Read next digit from the ACORDE raw data stream;\r
99 // return kFALSE in case of error or no digits left\r
100 //\r
101 // Input:\r
102 //\r
103 // Output:\r
104 //\r
105 // Created: 04 Feb 2008 Mario Sitta\r
106 //\r
107\r
108 if (fPosition >= 0) return kFALSE;\r
109\r
110 if (!fRawReader->ReadNextData(fData)) return kFALSE;\r
111 if (fRawReader->GetDataSize() == 0) return kFALSE;\r
112\r
113 fDataSize = fRawReader->GetDataSize();\r
114 if (fDataSize != 16) {\r
115 fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 5488",fDataSize));\r
116 AliWarning(Form("Wrong ACORDE raw data size: %d, expected 5488 bytes!",fDataSize));\r
117 return kFALSE;\r
118 }\r
119\r
120 fPosition = 0;\r
121\r
122 for (Int_t i=0; i<4; i++)\r
123 fWord[i] = GetNextWord();\r
124\r
125 return kTRUE;\r
126}\r
127\r
128//_____________________________________________________________________________\r
129UInt_t AliACORDERawStream::GetWord(Int_t index) const\r
130{\r
131 //\r
132 // Returns the ``index'' word from ACORDE raw data.\r
133 //\r
134 // Input:\r
135 // index : the index of the requested word\r
136 // Output:\r
137 // word : the 32 bit ``index'' word\r
138 //\r
139 // Created: 12 Feb 2008 Mario Sitta\r
140 //\r
141\r
142 if (index < 0 || index > 3) {\r
143 AliWarning(Form("Wrong word index %d, returning 0",index));\r
144 return 0;\r
145 } else {\r
146 return fWord[index];\r
147 }\r
148 \r
149}\r
150\r
151//_____________________________________________________________________________\r
152UInt_t AliACORDERawStream::GetNextWord()\r
153{\r
154 //\r
155 // Returns the next 32 bit word inside the raw data payload.\r
156 // The method is supposed to be endian (platform) independent.\r
157 //\r
158 // Input:\r
159 //\r
160 // Output:\r
161 // word : a 32 bit word containing the data\r
162 //\r
163 // Created: 04 Feb 2008 Mario Sitta\r
164 //\r
165\r
166 if (!fData || fPosition < 0)\r
167 AliFatal("Raw data payload buffer is not yet initialized !");\r
168\r
169 UInt_t word = 0;\r
170 word |= fData[fPosition++];\r
171 word |= fData[fPosition++] << 8;\r
172 word |= fData[fPosition++] << 16;\r
173 word |= fData[fPosition++] << 24;\r
174\r
175 return word;\r
176}\r
177\r
178//_____________________________________________________________________________\r
179UShort_t AliACORDERawStream::GetNextShort()\r
180{\r
181 //\r
182 // Returns the next 16 bit word inside the raw data payload.\r
183 // The method is supposed to be endian (platform) independent.\r
184 //\r
185 // Input:\r
186 //\r
187 // Output:\r
188 // word : a 16 bit word containing the data\r
189 //\r
190 // Created: 04 Feb 2008 Mario Sitta\r
191 //\r
192\r
193 if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");\r
194\r
195 UShort_t word = 0;\r
196 word |= fData[fPosition++];\r
197 word |= fData[fPosition++] << 8;\r
198\r
199 return word;\r
200}\r
201\r