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