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()) {
151 index += kRegEmptyScalerSize;
153 index += kRegEmptySize;
156 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
157 index += kRegHeaderSize;
159 fDDLTrigger->AddRegHeader(*fRegHeader);
160 // 11 regional scaler word
162 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
163 index += fRegHeader->GetScalerLength();
166 if (buffer[index++] != fRegHeader->GetEndOfReg()) {
168 const Char_t* msg = Form("Wrong end of Regional word %x instead of %x\n",
169 buffer[index-1], fRegHeader->GetEndOfReg());
170 if (fWarnings) AliWarning(msg);
171 AddErrorMessage(msg);
174 // 16 local cards per regional board
175 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
177 Int_t dataSize = fLocalStruct->GetLength();;
179 // 5 word trigger information
180 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
183 // 45 regional scaler word
185 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
186 index += fLocalStruct->GetScalerLength();
189 if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
191 const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
192 buffer[index-1], fLocalStruct->GetEndOfLocal());
194 if (fWarnings) AliWarning(msg);
195 AddErrorMessage(msg);
198 // fill only if card notified
199 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
202 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
206 } // regional card loop
212 //______________________________________________________
213 void AliMUONPayloadTrigger::ResetDDL()
215 /// reseting TClonesArray
218 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
219 darcHeader->GetRegHeaderArray()->Delete();
221 fGlobalEoWErrors = 0;
226 //______________________________________________________
227 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
229 /// set regional card number
230 if (reg > 8) reg = 8;
236 //______________________________________________________
237 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
239 /// set local card number
240 if (loc > 16) loc = 16;
244 //______________________________________________________
245 void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
247 /// adding message to logger
251 Int_t pos = tmp.First("\n");
254 fLog->Log(tmp.Data());