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 **************************************************************************/
17 /// \class AliMUONPayloadTrigger
20 /// Decodes rawdata from buffer and stores in TClonesArray.
22 /// First version implement for Trigger
24 /// \author Christian Finck
26 #include "AliMUONPayloadTrigger.h"
28 #include "AliMUONDarcHeader.h"
29 #include "AliMUONRegHeader.h"
30 #include "AliMUONLocalStruct.h"
31 #include "AliMUONDDLTrigger.h"
36 ClassImp(AliMUONPayloadTrigger)
39 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
43 fDDLTrigger(new AliMUONDDLTrigger()),
44 fRegHeader(new AliMUONRegHeader()),
45 fLocalStruct(new AliMUONLocalStruct())
48 /// create an object to read MUON raw digits
49 /// Default ctor for monitoring purposes
54 //___________________________________
55 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
66 //______________________________________________________
67 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
69 /// decode trigger DDL
70 /// store only notified cards
72 // reading DDL for trigger
74 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
76 static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength();
77 static Int_t kDarcHeaderSize = darcHeader->GetDarcHeaderLength();
78 static Int_t kRegHeaderSize = fRegHeader->GetHeaderLength();
80 Bool_t scalerEvent = kFALSE;
84 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
85 index += kDarcHeaderSize;
87 if(darcHeader->GetEventType() == 0) {
93 // 6 DARC scaler words
94 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
95 index += darcHeader->GetDarcScalerLength();
98 if (buffer[index++] != darcHeader->GetEndOfDarc())
100 AliError(Form("Wrong end of Darc word %x instead of %x\n",
101 buffer[index-1], darcHeader->GetEndOfDarc()));
104 // 4 words of global board input + Global board output
105 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
106 index += kGlobalHeaderSize;
109 // 10 Global scaler words
110 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
111 index += darcHeader->GetGlobalScalerLength();
114 if (buffer[index++] != darcHeader->GetEndOfGlobal())
116 AliError(Form("Wrong end of Global word %x instead of %x\n",
117 buffer[index-1], darcHeader->GetEndOfGlobal()));
121 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
123 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
124 index += kRegHeaderSize;
126 fDDLTrigger->AddRegHeader(*fRegHeader);
127 // 11 regional scaler word
129 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
130 index += fRegHeader->GetScalerLength();
133 if (buffer[index++] != fRegHeader->GetEndOfReg())
135 AliError(Form("Wrong end of Reg word %x instead of %x\n",
136 buffer[index-1], fRegHeader->GetEndOfReg()));
139 // 16 local cards per regional board
140 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
142 Int_t dataSize = fLocalStruct->GetLength();;
144 // 5 word trigger information
145 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
148 // 45 regional scaler word
150 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
151 index += fLocalStruct->GetScalerLength();
154 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
156 AliError(Form("Wrong end of local word %x instead of %x\n",
157 buffer[index-1], fLocalStruct->GetEndOfLocal()));
159 // fill only if card notified
160 if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
163 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
167 } // regional card loop
173 //______________________________________________________
174 void AliMUONPayloadTrigger::ResetDDL()
176 /// reseting TClonesArray
179 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
180 darcHeader->GetRegHeaderArray()->Delete();
183 //______________________________________________________
184 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
186 /// set regional card number
187 if (reg > 8) reg = 8;
191 //______________________________________________________
192 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
194 /// set local card number
195 if (loc > 16) loc = 16;