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();
94 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
95 index += kDarcHeaderSize;
99 if (darcHeader->GetDarcType() == 4)
103 if (darcHeader->GetDarcType() == 6)
106 if(darcHeader->GetEventType() == scalerEvent)
107 if (fWarnings) AliWarning("Wrong event type obtained from the Darc header, take the one of CDH");
111 // 6 DARC scaler words
112 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
113 index += darcHeader->GetDarcScalerLength();
116 if (buffer[index++] != darcHeader->GetEndOfDarc()) {
118 const Char_t* msg = Form("Wrong end of Darc word %x instead of %x\n",
119 buffer[index-1], darcHeader->GetEndOfDarc());
120 if (fWarnings) AliWarning(msg);
121 AddErrorMessage(msg);
124 // 4 words of global board input + Global board output
125 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
126 index += kGlobalHeaderSize;
129 // 10 Global scaler words
130 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
131 index += darcHeader->GetGlobalScalerLength();
134 if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
136 const Char_t* msg = Form("Wrong end of Global word %x instead of %x\n",
137 buffer[index-1], darcHeader->GetEndOfGlobal());
138 if (fWarnings) AliWarning(msg);
139 AddErrorMessage(msg);
143 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
145 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
146 index += kRegHeaderSize;
148 fDDLTrigger->AddRegHeader(*fRegHeader);
149 // 11 regional scaler word
151 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
152 index += fRegHeader->GetScalerLength();
155 if (buffer[index++] != fRegHeader->GetEndOfReg()) {
157 const Char_t* msg = Form("Wrong end of Regional word %x instead of %x\n",
158 buffer[index-1], fRegHeader->GetEndOfReg());
159 if (fWarnings) AliWarning(msg);
160 AddErrorMessage(msg);
163 // 16 local cards per regional board
164 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
166 Int_t dataSize = fLocalStruct->GetLength();;
168 // 5 word trigger information
169 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
172 // 45 regional scaler word
174 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
175 index += fLocalStruct->GetScalerLength();
178 if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
180 const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
181 buffer[index-1], fLocalStruct->GetEndOfLocal());
183 if (fWarnings) AliWarning(msg);
184 AddErrorMessage(msg);
187 // fill only if card notified
188 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
191 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
195 } // regional card loop
201 //______________________________________________________
202 void AliMUONPayloadTrigger::ResetDDL()
204 /// reseting TClonesArray
207 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
208 darcHeader->GetRegHeaderArray()->Delete();
210 fGlobalEoWErrors = 0;
215 //______________________________________________________
216 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
218 /// set regional card number
219 if (reg > 8) reg = 8;
225 //______________________________________________________
226 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
228 /// set local card number
229 if (loc > 16) loc = 16;
233 //______________________________________________________
234 void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
236 /// adding message to logger
240 Int_t pos = tmp.First("\n");
243 fLog->Log(tmp.Data());