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 "AliRawReader.h"
29 #include "AliRawDataHeader.h"
35 #include "AliMUONDarcHeader.h"
36 #include "AliMUONRegHeader.h"
37 #include "AliMUONLocalStruct.h"
38 #include "AliMUONDDLTrigger.h"
41 ClassImp(AliMUONPayloadTrigger)
44 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
48 fDDLTrigger(new AliMUONDDLTrigger()),
49 fRegHeader(new AliMUONRegHeader()),
50 fLocalStruct(new AliMUONLocalStruct())
53 /// create an object to read MUON raw digits
54 /// Default ctor for monitoring purposes
59 //___________________________________
60 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
71 //______________________________________________________
72 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
74 /// decode trigger DDL
75 /// store only non-empty structures (TrigY ==0)
77 // reading DDL for trigger
79 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
81 static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength();
82 static Int_t kDarcHeaderSize = darcHeader->GetDarcHeaderLength();
83 static Int_t kRegHeaderSize = fRegHeader->GetHeaderLength();
85 Bool_t scalerEvent = kFALSE;
89 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
90 index += kDarcHeaderSize;
92 if(darcHeader->GetEventType() == 0) {
98 // 6 DARC scaler words
99 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
100 index += darcHeader->GetDarcScalerLength();
103 if (buffer[index++] != darcHeader->GetEndOfDarc())
105 AliWarning(Form("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc()));
107 printf("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc());
110 // 4 words of global board input + Global board output
111 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4);
112 index += kGlobalHeaderSize;
115 // 10 Global scaler words
116 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
117 index += darcHeader->GetGlobalScalerLength();
120 if (buffer[index++] != darcHeader->GetEndOfGlobal())
122 AliWarning(Form("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
124 printf("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal());
128 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
130 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
131 index += kRegHeaderSize;
133 fDDLTrigger->AddRegHeader(*fRegHeader);
134 // 11 regional scaler word
136 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
137 index += fRegHeader->GetScalerLength();
140 if (buffer[index++] != fRegHeader->GetEndOfReg())
142 AliWarning(Form("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg()));
144 printf("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg());
147 // 16 local cards per regional board
148 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
150 Int_t dataSize = fLocalStruct->GetLength();;
152 // 5 word trigger information
153 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
156 // 45 regional scaler word
158 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
159 index += fLocalStruct->GetScalerLength();
162 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
164 AliWarning(Form("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
166 printf("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal());
169 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
173 } // regional card loop
179 //______________________________________________________
180 void AliMUONPayloadTrigger::ResetDDL()
182 /// reseting TClonesArray
185 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
186 darcHeader->GetRegHeaderArray()->Delete();
189 //______________________________________________________
190 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
192 /// set regional card number
193 if (reg > 8) reg = 8;
197 //______________________________________________________
198 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
200 /// set local card number
201 if (loc > 16) loc = 16;