]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONRawStreamTrigger.cxx
Decode new trigger board names
[u/mrichter/AliRoot.git] / MUON / AliMUONRawStreamTrigger.cxx
CommitLineData
972432c1 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///
19/// This class provides access to MUON digits in raw data.
20///
21/// It loops over all MUON digits in the raw data given by the AliRawReader.
22/// The Next method goes to the next digit. If there are no digits left
23/// it returns kFALSE(under develpment).
24/// It can loop also over DDL and store the decoded rawdata in TClonesArrays
25///
26/// First version implement for Trigger
27///
28///////////////////////////////////////////////////////////////////////////////
29
30#include "AliMUONRawStreamTrigger.h"
31
32#include "AliRawReader.h"
33#include "AliRawDataHeader.h"
34#include "AliLog.h"
35
36#include "AliMUONDarcHeader.h"
37#include "AliMUONRegHeader.h"
38#include "AliMUONLocalStruct.h"
39#include "AliMUONDDLTrigger.h"
40
41ClassImp(AliMUONRawStreamTrigger)
42
43AliMUONRawStreamTrigger::AliMUONRawStreamTrigger()
44 : TObject(),
45 fRawReader(0x0),
46 fDDL(0),
47 fSubEntries(0),
48 fNextDDL(kTRUE),
49 fMaxDDL(2),
50 fMaxReg(8),
51 fMaxLoc(16)
52{
53 //
54 // create an object to read MUON raw digits
55 // Default ctor for monitoring purposes
56 //
57
58 fDDLTrigger = new AliMUONDDLTrigger();
59 fRegHeader = new AliMUONRegHeader();
60 fLocalStruct = new AliMUONLocalStruct();
61
62}
63
64//_________________________________________________________________
65AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(AliRawReader* rawReader)
66 : TObject(),
67 fDDL(0),
68 fSubEntries(0),
69 fNextDDL(kTRUE),
70 fMaxDDL(2),
71 fMaxReg(8),
72 fMaxLoc(16)
73{
74 //
75 // ctor with AliRawReader as argument
76 // for reconstruction purpose
77 //
78
79 fRawReader = rawReader;
80
81 fDDLTrigger = new AliMUONDDLTrigger();
82 fRegHeader = new AliMUONRegHeader();
83 fLocalStruct = new AliMUONLocalStruct();
84
85}
86
87//_________________________________________________________________
88AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(const AliMUONRawStreamTrigger& stream) :
89 TObject(stream)
90{
91 //
92 // copy ctor
93 //
94 AliFatal("copy constructor not implemented");
95}
96
97//______________________________________________________________________
98AliMUONRawStreamTrigger& AliMUONRawStreamTrigger::operator = (const AliMUONRawStreamTrigger&
99 /* stream */)
100{
101 //
102 // assignment operator
103 //
104 AliFatal("assignment operator not implemented");
105 return *this;
106}
107
108//___________________________________
109AliMUONRawStreamTrigger::~AliMUONRawStreamTrigger()
110{
111 //
112 // clean up
113 //
114 delete fDDLTrigger;
115 delete fLocalStruct;
116 delete fRegHeader;
117}
118
119//_____________________________________________________________
120Bool_t AliMUONRawStreamTrigger::Next()
121{
122// read the next raw digit (buspatch structure)
123// returns kFALSE if there is no digit left
124
125// if (fNextDDL){
126// if(!NextDDL()) return kFALSE;
127// }
128// Int_t nEntries = fDDLTrigger->GetBusPatchEntries();
129
130// if (fSubEntries < nEntries) {
131// fLocalStruct = (AliMUONLocalStruct*)fDDLTrigger->GetBusPatchEntry(fSubEntries);
132// fSubEntries++;
133// fNextDDL = kFALSE;
134// return kTRUE;
135// } else {
136// fDDLTrigger->GetBusPatchArray()->Delete();
137// fSubEntries = 0;
138// fNextDDL = kTRUE;
139// return Next();
140// }
141
142 return kFALSE;
143}
144
145//______________________________________________________
146Bool_t AliMUONRawStreamTrigger::NextDDL()
147{
148 // reading tracker DDL
149 // store buspatch info into Array
150 // store only non-empty structures (buspatch info with datalength !=0)
151
152 // reading DDL for trigger
153
154 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
155
156 Int_t kDarcHeaderSize = darcHeader->GetHeaderLength();
157 Int_t kRegHeaderSize = fRegHeader->GetHeaderLength() ;
158 Bool_t scalerEvent = kFALSE;
159
160 // reset TClones
161 darcHeader->GetRegHeaderArray()->Delete();
162 //darcHeader->GetRegHeaderArray()->Clear("C");
163
164 // loop over the two ddl's
165 if (fDDL >= fMaxDDL) {
166 fDDL = 0;
167 return kFALSE;
168 }
169
170 fRawReader->Reset();
171 fRawReader->Select(0XA,fDDL,fDDL); //Select the DDL file to be read
172
173 fRawReader->ReadHeader();
174
175 Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
176 UInt_t *buffer = new UInt_t[totalDataWord/4];
177
178 fRawReader->ReadNext((UChar_t*)buffer, totalDataWord);
179
180 Int_t index = 0;
181 darcHeader->SetWord(buffer[index++]);
182
183 if(darcHeader->GetEventType() == 2) {
184 scalerEvent = kTRUE;
185 } else
186 scalerEvent = kFALSE;
187
188 if(scalerEvent) {
189 // 6 DARC scaler words
190 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
191 index += darcHeader->GetDarcScalerLength();
192 }
193
194 if (buffer[index++] != darcHeader->GetEndOfDarc())
195 AliWarning(Form("Wrong end of Darc word %d instead of %d\n",buffer[index-1], darcHeader->GetEndOfDarc()));
196
197 // 4 words of global board input + Global board output
198 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kDarcHeaderSize-1)*4);
199 index += kDarcHeaderSize- 1; // kind tricky cos scaler info in-between Darc header
200
201 if(scalerEvent) {
202 // 10 Global scaler words
203 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
204 index += darcHeader->GetGlobalScalerLength();
205 }
206
207 if (buffer[index++] != darcHeader->GetEndOfGlobal())
208 AliWarning(Form("Wrong end of Global word %d instead of %d\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
209
210 // 8 regional boards
211 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
212
213 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
214 index += kRegHeaderSize;
215
216 fDDLTrigger->AddRegHeader(*fRegHeader);
217 // 11 regional scaler word
218 if(scalerEvent) {
219 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
220 index += fRegHeader->GetScalerLength();
221 }
222
223 if (buffer[index++] != fRegHeader->GetEndOfReg())
224 AliWarning(Form("Wrong end of Reg word %d instead of %d\n",buffer[index-1], fRegHeader->GetEndOfReg()));
225
226 // 16 local cards per regional board
227 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
228
229 Int_t dataSize = fLocalStruct->GetLength();;
230
231 // 5 word trigger information
232 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
233 index += dataSize;
234
235 // 45 regional scaler word
236 if(scalerEvent) {
237 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
238 index += fLocalStruct->GetScalerLength();
239 }
240
241 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
242 AliWarning(Form("Wrong end of local word %d instead of %d\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
243
244 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
245
246 } // local card loop
247
248 } // regional card loop
249
250 delete [] buffer;
251
252
253 fDDL++;
254
255 return kTRUE;
256}
257
258//______________________________________________________
259void AliMUONRawStreamTrigger::ResetDDL()
260{
261 // reseting TClonesArray
262 // after each DDL
263 //
264 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
265 darcHeader->GetRegHeaderArray()->Clear("C");
266}
267
268//______________________________________________________
269void AliMUONRawStreamTrigger::SetMaxDDL(Int_t ddl)
270{
271 // set DDL number
272 if (ddl > 2) ddl = 2;
273 fMaxDDL = ddl;
274}
275
276//______________________________________________________
277void AliMUONRawStreamTrigger::SetMaxReg(Int_t reg)
278{
279 // set regional card number
280 if (reg > 8) reg = 8;
281 fMaxReg = reg;
282}
283
284//______________________________________________________
285void AliMUONRawStreamTrigger::SetMaxLoc(Int_t loc)
286{
287 // set local card number
288 if (loc > 16) loc = 16;
289 fMaxLoc = loc;
290}