]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONPayloadTrigger.cxx
Fix compilation warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTrigger.cxx
... / ...
CommitLineData
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// $Id$
17
18//-----------------------------------------------------------------------------
19/// \class AliMUONPayloadTrigger
20/// Class Payload
21///
22/// Decodes rawdata from buffer and stores in TClonesArray.
23///
24/// First version implement for Trigger
25///
26/// \author Christian Finck
27//-----------------------------------------------------------------------------
28
29#include "AliMUONPayloadTrigger.h"
30
31#include "AliMUONDarcHeader.h"
32#include "AliMUONRegHeader.h"
33#include "AliMUONLocalStruct.h"
34#include "AliMUONDDLTrigger.h"
35#include "AliMUONLogger.h"
36
37#include "AliLog.h"
38
39/// \cond CLASSIMP
40ClassImp(AliMUONPayloadTrigger)
41/// \endcond
42
43AliMUONPayloadTrigger::AliMUONPayloadTrigger()
44 : TObject(),
45 fMaxReg(8),
46 fMaxLoc(16),
47 fDDLTrigger(new AliMUONDDLTrigger()),
48 fRegHeader(new AliMUONRegHeader()),
49 fLocalStruct(new AliMUONLocalStruct()),
50 fLog(new AliMUONLogger(1000)),
51 fDarcEoWErrors(0),
52 fGlobalEoWErrors(0),
53 fRegEoWErrors(0),
54 fLocalEoWErrors(0),
55 fWarnings(kTRUE),
56 fNofRegSet(kFALSE)
57{
58 ///
59 /// create an object to read MUON raw digits
60 /// Default ctor for monitoring purposes
61 ///
62
63}
64
65//___________________________________
66AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
67{
68 ///
69 /// clean up
70 ///
71 delete fDDLTrigger;
72 delete fLocalStruct;
73 delete fRegHeader;
74 delete fLog;
75}
76
77
78//______________________________________________________
79Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer, Bool_t scalerEvent)
80{
81 /// decode trigger DDL
82 /// store only notified cards
83
84 // reading DDL for trigger
85
86 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
87
88 static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength();
89 static Int_t kDarcHeaderSize = darcHeader->GetDarcHeaderLength();
90 static Int_t kRegHeaderSize = fRegHeader->GetHeaderLength();
91 static Int_t kRegEmptySize = fRegHeader->GetHeaderLength()+1 + 16*(fLocalStruct->GetLength()+1);
92 static Int_t kRegEmptyScalerSize = fRegHeader->GetHeaderLength() + fRegHeader->GetScalerLength() + 1 +
93 16*(fLocalStruct->GetLength() + fLocalStruct->GetScalerLength() + 1);
94
95 Int_t index = 0;
96
97 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
98 index += kDarcHeaderSize;
99
100
101 // darc type vadorh
102 if (darcHeader->GetDarcType() == darcHeader->GetDarcVadohrType())
103 fMaxReg = 1;
104
105 // darc type def.
106 if (darcHeader->GetDarcType() == darcHeader->GetDarcDefaultType())
107 fMaxReg = 8;
108
109 if(darcHeader->GetEventType() == scalerEvent)
110 if (fWarnings) AliWarning("Wrong event type obtained from the Darc header, take the one of CDH");
111
112
113 if(scalerEvent) {
114 // 6 DARC scaler words
115 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
116 index += darcHeader->GetDarcScalerLength();
117 }
118
119 if (buffer[index++] != darcHeader->GetEndOfDarc()) {
120
121 const Char_t* msg = Form("Wrong end of Darc word %x instead of %x\n",
122 buffer[index-1], darcHeader->GetEndOfDarc());
123 if (fWarnings) AliWarning(msg);
124 AddErrorMessage(msg);
125 fDarcEoWErrors++;
126 }
127 // 4 words of global board input + Global board output
128 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
129 index += kGlobalHeaderSize;
130
131 if(scalerEvent) {
132 // 10 Global scaler words
133 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
134 index += darcHeader->GetGlobalScalerLength();
135 }
136
137 if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
138
139 const Char_t* msg = Form("Wrong end of Global word %x instead of %x\n",
140 buffer[index-1], darcHeader->GetEndOfGlobal());
141 if (fWarnings) AliWarning(msg);
142 AddErrorMessage(msg);
143 fGlobalEoWErrors++;
144 }
145 // 8 regional boards
146 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
147
148 // skip empty regaional board (not connected or with error reading)
149 if (buffer[index] == fRegHeader->GetErrorWord()) {
150 fDDLTrigger->AddRegHeader(*fRegHeader);
151 if (scalerEvent)
152 index += kRegEmptyScalerSize;
153 else
154 index += kRegEmptySize;
155 continue;
156 }
157 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
158 index += kRegHeaderSize;
159
160 fDDLTrigger->AddRegHeader(*fRegHeader);
161 // 11 regional scaler word
162 if(scalerEvent) {
163 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
164 index += fRegHeader->GetScalerLength();
165 }
166
167 if (buffer[index++] != fRegHeader->GetEndOfReg()) {
168
169 const Char_t* msg = Form("Wrong end of Regional word %x instead of %x\n",
170 buffer[index-1], fRegHeader->GetEndOfReg());
171 if (fWarnings) AliWarning(msg);
172 AddErrorMessage(msg);
173 fRegEoWErrors++;
174 }
175 // 16 local cards per regional board
176 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
177
178 Int_t dataSize = fLocalStruct->GetLength();;
179
180 // 5 word trigger information
181 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
182 index += dataSize;
183
184 // 45 regional scaler word
185 if(scalerEvent) {
186 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
187 index += fLocalStruct->GetScalerLength();
188 }
189
190 if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
191
192 const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
193 buffer[index-1], fLocalStruct->GetEndOfLocal());
194
195 if (fWarnings) AliWarning(msg);
196 AddErrorMessage(msg);
197 fLocalEoWErrors++;
198 }
199 // fill only if card notified
200 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
201 continue;
202
203 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
204
205 } // local card loop
206
207 } // regional card loop
208
209
210 return kTRUE;
211}
212
213//______________________________________________________
214void AliMUONPayloadTrigger::ResetDDL()
215{
216 /// reseting TClonesArray
217 /// after each DDL
218 ///
219 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
220 darcHeader->GetRegHeaderArray()->Delete();
221 fDarcEoWErrors = 0;
222 fGlobalEoWErrors = 0;
223 fRegEoWErrors = 0;
224 fLocalEoWErrors = 0;
225}
226
227//______________________________________________________
228void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
229{
230 /// set regional card number
231 if (reg > 8) reg = 8;
232 fMaxReg = reg;
233
234 fNofRegSet = kTRUE;
235}
236
237//______________________________________________________
238void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
239{
240 /// set local card number
241 if (loc > 16) loc = 16;
242 fMaxLoc = loc;
243}
244
245//______________________________________________________
246void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
247{
248/// adding message to logger
249
250 TString tmp(msg);
251
252 Int_t pos = tmp.First("\n");
253 tmp[pos] = 0;
254
255 fLog->Log(tmp.Data());
256}
257