]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ACORDE/AliACORDERawStream.cxx
Update version number in order to avoid warnings from root
[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
820ad81a 26#include "AliRawReaderRoot.h"\r
03e41177 27\r
28ClassImp(AliACORDERawStream)\r
29\r
30//_____________________________________________________________________________\r
31AliACORDERawStream::AliACORDERawStream(AliRawReader* rawReader) :\r
32 fRawReader(rawReader),\r
33 fPosition(-1),\r
34 fData(NULL),\r
35 fDataSize(0)\r
36{\r
37 //\r
38 // Create an object to read ACORDE raw data\r
39 //\r
40 // Created: 04 Feb 2008 Mario Sitta\r
41 //\r
42\r
43 // Select the raw data corresponding to the ACORDE detector id\r
44// fRawReader->Reset();\r
45 AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("ACORDE")));\r
46 fRawReader->Select("ACORDE");\r
47\r
48}\r
49\r
50//_____________________________________________________________________________\r
51AliACORDERawStream::AliACORDERawStream(const AliACORDERawStream &r) :\r
52 TObject(),\r
53 fRawReader(r.fRawReader),\r
54 fPosition(-1),\r
55 fData(NULL),\r
56 fDataSize(0)\r
57{\r
58 // Simple copy constructor\r
59 ((AliACORDERawStream &) r).Copy(*this);\r
60}\r
61\r
62//_____________________________________________________________________________\r
63AliACORDERawStream::~AliACORDERawStream()\r
64{\r
65 // Default destructor\r
66}\r
67\r
68//_____________________________________________________________________________\r
69AliACORDERawStream &AliACORDERawStream::operator=(const AliACORDERawStream &r)\r
70{\r
71 // Simple operator=\r
72 if (this != &r) ((AliACORDERawStream &) r).Copy(*this);\r
73 return *this;\r
74}\r
75\r
76//_____________________________________________________________________________\r
77void AliACORDERawStream::Reset()\r
78{\r
79 //\r
80 // Reset the raw stream parameters\r
81 //\r
82 // Input:\r
83 //\r
84 // Output:\r
85 //\r
86 // Created: 04 Feb 2008 Mario Sitta\r
87 //\r
88\r
89 fPosition = -1;\r
90 fData = NULL;\r
91\r
92 if (fRawReader) fRawReader->Reset();\r
93}\r
94\r
95//_____________________________________________________________________________\r
96Bool_t AliACORDERawStream::Next()\r
97{\r
98 //\r
99 // Read next digit from the ACORDE raw data stream;\r
100 // return kFALSE in case of error or no digits left\r
101 //\r
102 // Input:\r
103 //\r
104 // Output:\r
105 //\r
106 // Created: 04 Feb 2008 Mario Sitta\r
107 //\r
108\r
109 if (fPosition >= 0) return kFALSE;\r
110\r
111 if (!fRawReader->ReadNextData(fData)) return kFALSE;\r
112 if (fRawReader->GetDataSize() == 0) return kFALSE;\r
113\r
114 fDataSize = fRawReader->GetDataSize();\r
115 if (fDataSize != 16) {\r
116 fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 5488",fDataSize));\r
117 AliWarning(Form("Wrong ACORDE raw data size: %d, expected 5488 bytes!",fDataSize));\r
118 return kFALSE;\r
119 }\r
120\r
121 fPosition = 0;\r
122\r
123 for (Int_t i=0; i<4; i++)\r
124 fWord[i] = GetNextWord();\r
125\r
126 return kTRUE;\r
127}\r
128\r
129//_____________________________________________________________________________\r
130UInt_t AliACORDERawStream::GetWord(Int_t index) const\r
131{\r
132 //\r
133 // Returns the ``index'' word from ACORDE raw data.\r
134 //\r
135 // Input:\r
136 // index : the index of the requested word\r
137 // Output:\r
138 // word : the 32 bit ``index'' word\r
139 //\r
140 // Created: 12 Feb 2008 Mario Sitta\r
141 //\r
142\r
143 if (index < 0 || index > 3) {\r
144 AliWarning(Form("Wrong word index %d, returning 0",index));\r
145 return 0;\r
146 } else {\r
147 return fWord[index];\r
148 }\r
149 \r
150}\r
151\r
152//_____________________________________________________________________________\r
153UInt_t AliACORDERawStream::GetNextWord()\r
154{\r
155 //\r
156 // Returns the next 32 bit word inside the raw data payload.\r
157 // The method is supposed to be endian (platform) independent.\r
158 //\r
159 // Input:\r
160 //\r
161 // Output:\r
162 // word : a 32 bit word containing the data\r
163 //\r
164 // Created: 04 Feb 2008 Mario Sitta\r
165 //\r
166\r
167 if (!fData || fPosition < 0)\r
168 AliFatal("Raw data payload buffer is not yet initialized !");\r
169\r
170 UInt_t word = 0;\r
171 word |= fData[fPosition++];\r
172 word |= fData[fPosition++] << 8;\r
173 word |= fData[fPosition++] << 16;\r
174 word |= fData[fPosition++] << 24;\r
175\r
176 return word;\r
177}\r
178\r
179//_____________________________________________________________________________\r
180UShort_t AliACORDERawStream::GetNextShort()\r
181{\r
182 //\r
183 // Returns the next 16 bit word inside the raw data payload.\r
184 // The method is supposed to be endian (platform) independent.\r
185 //\r
186 // Input:\r
187 //\r
188 // Output:\r
189 // word : a 16 bit word containing the data\r
190 //\r
191 // Created: 04 Feb 2008 Mario Sitta\r
192 //\r
193\r
194 if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");\r
195\r
196 UShort_t word = 0;\r
197 word |= fData[fPosition++];\r
198 word |= fData[fPosition++] << 8;\r
199\r
200 return word;\r
201}\r
202\r
820ad81a 203//_____________________________________________________________________________\r
204\r
205Int_t AliACORDERawStream::GetNEvents(char* fileName) \r
206{\r
207 // Returns the Total Number of Events recorded by ACORDE \r
208 // Note: it may be a better way to do it !!\r
209 // Input: fileName to Analyze\r
210 // Output: Number of Total Events (fNEvents) in fileName\r
211 // Created: 25 March 2008\r
212 // Author: Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>\r
213 \r
214 AliRawReader* rCount = new AliRawReaderRoot(fileName);\r
215 Int_t DyM=0;\r
216 Int_t fNEvents=0;\r
217 while(DyM==0)\r
218 {\r
219 if (!rCount->NextEvent()) DyM=1;\r
220 else fNEvents++;\r
221 }\r
222 return fNEvents;\r
223}\r
224\r
225//____________________________________________________________________________\r