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)),
58 /// create an object to read MUON raw digits
59 /// Default ctor for monitoring purposes
64 //___________________________________
65 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
77 //______________________________________________________
78 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
80 /// decode trigger DDL
81 /// store only notified cards
83 // reading DDL for trigger
85 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
87 static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength();
88 static Int_t kDarcHeaderSize = darcHeader->GetDarcHeaderLength();
89 static Int_t kRegHeaderSize = fRegHeader->GetHeaderLength();
91 Bool_t scalerEvent = kFALSE;
95 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
96 index += kDarcHeaderSize;
98 if(darcHeader->GetEventType() == 0) {
101 scalerEvent = kFALSE;
104 // 6 DARC scaler words
105 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
106 index += darcHeader->GetDarcScalerLength();
109 if (buffer[index++] != darcHeader->GetEndOfDarc()) {
111 const Char_t* msg = Form("Wrong end of Darc word %x instead of %x\n",
112 buffer[index-1], darcHeader->GetEndOfDarc());
113 if (fWarnings) AliWarning(msg);
114 AddErrorMessage(msg);
117 // 4 words of global board input + Global board output
118 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
119 index += kGlobalHeaderSize;
122 // 10 Global scaler words
123 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
124 index += darcHeader->GetGlobalScalerLength();
127 if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
129 const Char_t* msg = Form("Wrong end of Global word %x instead of %x\n",
130 buffer[index-1], darcHeader->GetEndOfGlobal());
131 if (fWarnings) AliWarning(msg);
132 AddErrorMessage(msg);
136 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
138 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
139 index += kRegHeaderSize;
141 fDDLTrigger->AddRegHeader(*fRegHeader);
142 // 11 regional scaler word
144 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
145 index += fRegHeader->GetScalerLength();
148 if (buffer[index++] != fRegHeader->GetEndOfReg()) {
150 const Char_t* msg = Form("Wrong end of Regional word %x instead of %x\n",
151 buffer[index-1], fRegHeader->GetEndOfReg());
152 if (fWarnings) AliWarning(msg);
153 AddErrorMessage(msg);
156 // 16 local cards per regional board
157 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
159 Int_t dataSize = fLocalStruct->GetLength();;
161 // 5 word trigger information
162 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
165 // 45 regional scaler word
167 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
168 index += fLocalStruct->GetScalerLength();
171 if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
173 const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
174 buffer[index-1], fLocalStruct->GetEndOfLocal());
176 if (fWarnings) AliWarning(msg);
177 AddErrorMessage(msg);
180 // fill only if card notified
181 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
184 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
188 } // regional card loop
194 //______________________________________________________
195 void AliMUONPayloadTrigger::ResetDDL()
197 /// reseting TClonesArray
200 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
201 darcHeader->GetRegHeaderArray()->Delete();
203 fGlobalEoWErrors = 0;
208 //______________________________________________________
209 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
211 /// set regional card number
212 if (reg > 8) reg = 8;
216 //______________________________________________________
217 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
219 /// set local card number
220 if (loc > 16) loc = 16;
224 //______________________________________________________
225 void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
227 /// adding message to logger
231 Int_t pos = tmp.First("\n");
234 fLog->Log(tmp.Data());