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)
92 // reading tracker DDL
93 // store buspatch info into Array
94 // store only non-empty structures (buspatch info with datalength !=0)
96 // reading DDL for trigger
98 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
100 Int_t kDarcHeaderSize = darcHeader->GetHeaderLength();
101 Int_t kRegHeaderSize = fRegHeader->GetHeaderLength() ;
102 Bool_t scalerEvent = kFALSE;
105 darcHeader->SetWord(buffer[index++]);
107 if(darcHeader->GetEventType() == 2) {
110 scalerEvent = kFALSE;
113 // 6 DARC scaler words
114 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
115 index += darcHeader->GetDarcScalerLength();
118 if (buffer[index++] != darcHeader->GetEndOfDarc())
119 AliWarning(Form("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc()));
121 // 4 words of global board input + Global board output
122 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kDarcHeaderSize-1)*4);
123 index += kDarcHeaderSize- 1; // kind tricky cos scaler info in-between Darc header
126 // 10 Global scaler words
127 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
128 index += darcHeader->GetGlobalScalerLength();
131 if (buffer[index++] != darcHeader->GetEndOfGlobal())
132 AliWarning(Form("Wrong end of Global word %d instead of %d\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
135 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
137 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
138 index += kRegHeaderSize;
140 fDDLTrigger->AddRegHeader(*fRegHeader);
141 // 11 regional scaler word
143 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
144 index += fRegHeader->GetScalerLength();
147 if (buffer[index++] != fRegHeader->GetEndOfReg())
148 AliWarning(Form("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg()));
150 // 16 local cards per regional board
151 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
153 Int_t dataSize = fLocalStruct->GetLength();;
155 // 5 word trigger information
156 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
159 // 45 regional scaler word
161 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
162 index += fLocalStruct->GetScalerLength();
165 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
166 AliWarning(Form("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
168 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
172 } // regional card loop
178 //______________________________________________________
179 void AliMUONPayloadTrigger::ResetDDL()
181 // reseting TClonesArray
184 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
185 darcHeader->GetRegHeaderArray()->Delete();
188 //______________________________________________________
189 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
191 // set regional card number
192 if (reg > 8) reg = 8;
196 //______________________________________________________
197 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
199 // set local card number
200 if (loc > 16) loc = 16;