1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONPayloadTrigger
22 /// Decodes rawdata from buffer and stores in TClonesArray.
24 /// First version implement for Trigger
26 /// \author Christian Finck
27 //-----------------------------------------------------------------------------
29 #include "AliMUONPayloadTrigger.h"
31 #include "AliMUONDarcHeader.h"
32 #include "AliMUONRegHeader.h"
33 #include "AliMUONLocalStruct.h"
34 #include "AliMUONDDLTrigger.h"
35 #include "AliMUONLogger.h"
40 ClassImp(AliMUONPayloadTrigger)
43 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
47 fDDLTrigger(new AliMUONDDLTrigger()),
48 fRegHeader(new AliMUONRegHeader()),
49 fLocalStruct(new AliMUONLocalStruct()),
50 fLog(new AliMUONLogger(1000)),
59 /// create an object to read MUON raw digits
60 /// Default ctor for monitoring purposes
65 //___________________________________
66 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
78 //______________________________________________________
79 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer, Bool_t scalerEvent)
81 /// decode trigger DDL
82 /// store only notified cards
84 // reading DDL for trigger
86 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
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);
97 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
98 index += kDarcHeaderSize;
102 if (darcHeader->GetDarcType() == darcHeader->GetDarcVadohrType())
106 if (darcHeader->GetDarcType() == darcHeader->GetDarcDefaultType())
109 if(darcHeader->GetEventType() == scalerEvent)
110 if (fWarnings) AliWarning("Wrong event type obtained from the Darc header, take the one of CDH");
114 // 6 DARC scaler words
115 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
116 index += darcHeader->GetDarcScalerLength();
119 if (buffer[index++] != darcHeader->GetEndOfDarc()) {
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);
127 // 4 words of global board input + Global board output
128 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
129 index += kGlobalHeaderSize;
132 // 10 Global scaler words
133 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
134 index += darcHeader->GetGlobalScalerLength();
137 if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
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);
146 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
148 // skip empty regaional board (not connected or with error reading)
149 if (buffer[index] == fRegHeader->GetErrorWord()) {
150 fDDLTrigger->AddRegHeader(*fRegHeader);
152 index += kRegEmptyScalerSize;
154 index += kRegEmptySize;
157 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
158 index += kRegHeaderSize;
160 fDDLTrigger->AddRegHeader(*fRegHeader);
161 // 11 regional scaler word
163 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
164 index += fRegHeader->GetScalerLength();
167 if (buffer[index++] != fRegHeader->GetEndOfReg()) {
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);
175 // 16 local cards per regional board
176 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
178 Int_t dataSize = fLocalStruct->GetLength();;
180 // 5 word trigger information
181 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
184 // 45 regional scaler word
186 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
187 index += fLocalStruct->GetScalerLength();
190 if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
192 const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
193 buffer[index-1], fLocalStruct->GetEndOfLocal());
195 if (fWarnings) AliWarning(msg);
196 AddErrorMessage(msg);
199 // fill only if card notified
200 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
203 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
207 } // regional card loop
213 //______________________________________________________
214 void AliMUONPayloadTrigger::ResetDDL()
216 /// reseting TClonesArray
219 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
220 darcHeader->GetRegHeaderArray()->Delete();
222 fGlobalEoWErrors = 0;
227 //______________________________________________________
228 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
230 /// set regional card number
231 if (reg > 8) reg = 8;
237 //______________________________________________________
238 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
240 /// set local card number
241 if (loc > 16) loc = 16;
245 //______________________________________________________
246 void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
248 /// adding message to logger
252 Int_t pos = tmp.First("\n");
255 fLog->Log(tmp.Data());