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