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