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 ///////////////////////////////////////////////////////////////////////////////
21 /// Decodes rawdata from buffer and stores in TClonesArray.
23 /// First version implement for Trigger
25 ///////////////////////////////////////////////////////////////////////////////
27 #include "AliMUONPayloadTrigger.h"
29 #include "AliRawReader.h"
30 #include "AliRawDataHeader.h"
33 #include "AliMUONDarcHeader.h"
34 #include "AliMUONRegHeader.h"
35 #include "AliMUONLocalStruct.h"
36 #include "AliMUONDDLTrigger.h"
38 ClassImp(AliMUONPayloadTrigger)
40 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
46 // create an object to read MUON raw digits
47 // Default ctor for monitoring purposes
50 fDDLTrigger = new AliMUONDDLTrigger();
51 fRegHeader = new AliMUONRegHeader();
52 fLocalStruct = new AliMUONLocalStruct();
56 //_________________________________________________________________
57 AliMUONPayloadTrigger::AliMUONPayloadTrigger(const AliMUONPayloadTrigger& stream) :
63 AliFatal("copy constructor not implemented");
66 //______________________________________________________________________
67 AliMUONPayloadTrigger& AliMUONPayloadTrigger::operator = (const AliMUONPayloadTrigger&
71 // assignment operator
73 AliFatal("assignment operator not implemented");
77 //___________________________________
78 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
89 //______________________________________________________
90 Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
93 // store only non-empty structures (TrigY ==0)
95 // reading DDL for trigger
97 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
99 static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength();
100 static Int_t kDarcHeaderSize = darcHeader->GetDarcHeaderLength();
101 static Int_t kRegHeaderSize = fRegHeader->GetHeaderLength();
103 Bool_t scalerEvent = kFALSE;
107 memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4);
108 index += kDarcHeaderSize;
110 if(darcHeader->GetEventType() == 2) {
113 scalerEvent = kFALSE;
116 // 6 DARC scaler words
117 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
118 index += darcHeader->GetDarcScalerLength();
121 if (buffer[index++] != darcHeader->GetEndOfDarc())
122 AliWarning(Form("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc()));
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())
135 AliWarning(Form("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
138 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
140 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
141 index += kRegHeaderSize;
143 fDDLTrigger->AddRegHeader(*fRegHeader);
144 // 11 regional scaler word
146 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
147 index += fRegHeader->GetScalerLength();
150 if (buffer[index++] != fRegHeader->GetEndOfReg())
151 AliWarning(Form("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg()));
153 // 16 local cards per regional board
154 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
156 Int_t dataSize = fLocalStruct->GetLength();;
158 // 5 word trigger information
159 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
162 // 45 regional scaler word
164 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
165 index += fLocalStruct->GetScalerLength();
168 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
169 AliWarning(Form("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
171 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
175 } // regional card loop
181 //______________________________________________________
182 void AliMUONPayloadTrigger::ResetDDL()
184 // reseting TClonesArray
187 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
188 darcHeader->GetRegHeaderArray()->Delete();
191 //______________________________________________________
192 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
194 // set regional card number
195 if (reg > 8) reg = 8;
199 //______________________________________________________
200 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
202 // set local card number
203 if (loc > 16) loc = 16;