]>
Commit | Line | Data |
---|---|---|
2eb38194 | 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 the VZERO DDL raw data | |
19 | /// The format of the raw data corresponds to the one | |
20 | /// implemented in AliVZEROBuffer class. | |
21 | /// | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliVZERORawStream.h" | |
25 | #include "AliRawReader.h" | |
26 | #include "AliLog.h" | |
27 | #include "AliDAQ.h" | |
28 | ||
29 | ClassImp(AliVZERORawStream) | |
30 | ||
31 | //_____________________________________________________________________________ | |
32 | AliVZERORawStream::AliVZERORawStream(AliRawReader* rawReader) : | |
726d762c | 33 | fTrigger(0), |
34 | fTriggerMask(0), | |
2eb38194 | 35 | fPosition(-1), |
36 | fRawReader(rawReader), | |
37 | fData(NULL) | |
38 | { | |
39 | // create an object to read VZERO raw data | |
40 | // | |
41 | // select the raw data corresponding to | |
42 | // the VZERO detector id | |
43 | fRawReader->Reset(); | |
44 | AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("VZERO"))); | |
45 | fRawReader->Select("VZERO"); | |
726d762c | 46 | |
47 | // Initalize the containers | |
48 | for(Int_t i = 0; i < kNChannels; i++) { | |
49 | fTime[i] = fWidth[i] = 0; | |
50 | for(Int_t j = 0; j < kNEvOfInt; j++) { | |
51 | fADC[i][j] = 0; | |
52 | fIsInt[i][j] = fIsBB[i][j] = fIsBG[i][j] = kFALSE; | |
53 | } | |
54 | fBBScalers[i] = fBGScalers[i] = 0; | |
55 | for(Int_t j = 0; j < kNBunches; j++) { | |
56 | fChargeMB[i][j] = 0; | |
57 | fIsIntMB[i][j] = fIsBBMB[i][j] = fIsBGMB[i][j] = kFALSE; | |
58 | } | |
59 | } | |
60 | for(Int_t i = 0; i < kNScalers; i++) fScalers[i] = 0; | |
61 | for(Int_t i = 0; i < kNBunches; i++) fBunchNumbers[i] = 0; | |
2eb38194 | 62 | } |
63 | ||
64 | //_____________________________________________________________________________ | |
65 | AliVZERORawStream::~AliVZERORawStream() | |
66 | { | |
67 | // destructor | |
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | void AliVZERORawStream::Reset() | |
72 | { | |
73 | // reset raw stream params | |
74 | ||
726d762c | 75 | // Reinitalize the containers |
76 | for(Int_t i = 0; i < kNChannels; i++) { | |
77 | fTime[i] = fWidth[i] = 0; | |
78 | for(Int_t j = 0; j < kNEvOfInt; j++) { | |
79 | fADC[i][j] = 0; | |
80 | fIsInt[i][j] = fIsBB[i][j] = fIsBG[i][j] = kFALSE; | |
81 | } | |
82 | fBBScalers[i] = fBGScalers[i] = 0; | |
83 | for(Int_t j = 0; j < kNBunches; j++) { | |
84 | fChargeMB[i][j] = 0; | |
85 | fIsIntMB[i][j] = fIsBBMB[i][j] = fIsBGMB[i][j] = kFALSE; | |
86 | } | |
87 | } | |
88 | for(Int_t i = 0; i < kNScalers; i++) fScalers[i] = 0; | |
89 | for(Int_t i = 0; i < kNBunches; i++) fBunchNumbers[i] = 0; | |
90 | ||
91 | fTrigger = fTriggerMask = 0; | |
92 | fPosition = -1; | |
93 | fData = NULL; | |
2eb38194 | 94 | |
95 | if (fRawReader) fRawReader->Reset(); | |
96 | } | |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | Bool_t AliVZERORawStream::Next() | |
100 | { | |
101 | // read next digit from the VZERO raw data stream | |
102 | // return kFALSE in case of error or no digits left | |
103 | ||
726d762c | 104 | if (fPosition >= 0) return kFALSE; |
105 | ||
106 | if (!fRawReader->ReadNextData(fData)) return kFALSE; | |
107 | if (fRawReader->GetDataSize() == 0) return kFALSE; | |
108 | ||
109 | if (fRawReader->GetDataSize() != 5488) { | |
110 | fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 5488",fRawReader->GetDataSize())); | |
111 | AliWarning(Form("Wrong VZERO raw data size: %d, expected 5488 bytes!",fRawReader->GetDataSize())); | |
2eb38194 | 112 | return kFALSE; |
726d762c | 113 | } |
114 | ||
115 | fPosition = 0; | |
116 | ||
117 | fTrigger = GetNextWord() & 0xffff; | |
118 | fTriggerMask = GetNextWord() & 0xffff; | |
119 | ||
120 | for(Int_t iChannel = 0; iChannel < kNChannels; iChannel++) { | |
121 | for(Int_t iEvOfInt = 0; iEvOfInt < kNEvOfInt; iEvOfInt++) { | |
122 | UShort_t data = GetNextShort(); | |
123 | fADC[iChannel][iEvOfInt] = data & 0x3ff; | |
124 | fIsInt[iChannel][iEvOfInt] = (data >> 10) & 0x1; | |
125 | fIsBB[iChannel][iEvOfInt] = (data >> 11) & 0x1; | |
126 | fIsBG[iChannel][iEvOfInt] = (data >> 12) & 0x1; | |
2eb38194 | 127 | } |
726d762c | 128 | GetNextShort(); |
129 | ||
130 | UInt_t time = GetNextWord(); | |
131 | fTime[iChannel] = time & 0xfff; | |
132 | fWidth[iChannel] = (time >> 12) & 0x7f; | |
2eb38194 | 133 | } |
134 | ||
726d762c | 135 | for(Int_t iScaler = 0; iScaler < kNScalers; iScaler++) |
136 | fScalers[iScaler] = GetNextWord(); | |
137 | ||
138 | for(Int_t iChannel = 0; iChannel < kNChannels; iChannel++) { | |
139 | fBBScalers[iChannel] = ((ULong64_t)GetNextWord()) << 32; | |
140 | fBBScalers[iChannel] |= GetNextWord(); | |
2eb38194 | 141 | |
726d762c | 142 | fBGScalers[iChannel] = ((ULong64_t)GetNextWord()) << 32; |
143 | fBGScalers[iChannel] |= GetNextWord(); | |
144 | } | |
145 | ||
146 | for(Int_t iBunch = 0; iBunch < kNBunches; iBunch++) | |
147 | fBunchNumbers[iBunch] = GetNextWord(); | |
148 | ||
149 | for(Int_t iChannel = 0; iChannel < kNChannels; iChannel++) { | |
150 | for(Int_t iBunch = 0; iBunch < kNBunches; iBunch++) { | |
151 | UShort_t data = GetNextShort(); | |
152 | fChargeMB[iChannel][iBunch] = data & 0x3ff; | |
153 | fIsIntMB[iChannel][iBunch] = (data >> 10) & 0x1; | |
154 | fIsBBMB[iChannel][iBunch] = (data >> 11) & 0x1; | |
155 | fIsBGMB[iChannel][iBunch] = (data >> 12) & 0x1; | |
156 | } | |
157 | } | |
2eb38194 | 158 | |
159 | return kTRUE; | |
160 | } | |
161 | ||
162 | //_____________________________________________________________________________ | |
726d762c | 163 | UInt_t AliVZERORawStream::GetNextWord() |
2eb38194 | 164 | { |
165 | // This method returns the next 32 bit word | |
166 | // inside the raw data payload. | |
167 | // The method is supposed to be endian (platform) | |
168 | // independent. | |
169 | if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !"); | |
170 | ||
726d762c | 171 | UInt_t word = 0; |
2eb38194 | 172 | word |= fData[fPosition++]; |
173 | word |= fData[fPosition++] << 8; | |
174 | word |= fData[fPosition++] << 16; | |
175 | word |= fData[fPosition++] << 24; | |
176 | ||
177 | return word; | |
178 | } | |
726d762c | 179 | |
180 | //_____________________________________________________________________________ | |
181 | UShort_t AliVZERORawStream::GetNextShort() | |
182 | { | |
183 | // This method returns the next 16 bit word | |
184 | // inside the raw data payload. | |
185 | // The method is supposed to be endian (platform) | |
186 | // independent. | |
187 | if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !"); | |
188 | ||
189 | UShort_t word = 0; | |
190 | word |= fData[fPosition++]; | |
191 | word |= fData[fPosition++] << 8; | |
192 | ||
193 | return word; | |
194 | } |