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 ///////////////////////////////////////////////////////////////////////////////
19 /// This class provides access to MUON digits in raw data.
21 /// It loops over all MUON digits in the raw data given by the AliRawReader.
22 /// The Next method goes to the next digit. If there are no digits left
23 /// it returns kFALSE(under develpment).
24 /// It can loop also over DDL and store the decoded rawdata in TClonesArrays
26 /// First version implement for Trigger
28 ///////////////////////////////////////////////////////////////////////////////
30 #include "AliMUONRawStreamTrigger.h"
32 #include "AliRawReader.h"
33 #include "AliRawDataHeader.h"
36 #include "AliMUONDarcHeader.h"
37 #include "AliMUONRegHeader.h"
38 #include "AliMUONLocalStruct.h"
39 #include "AliMUONDDLTrigger.h"
41 ClassImp(AliMUONRawStreamTrigger)
43 AliMUONRawStreamTrigger::AliMUONRawStreamTrigger()
54 // create an object to read MUON raw digits
55 // Default ctor for monitoring purposes
58 fDDLTrigger = new AliMUONDDLTrigger();
59 fRegHeader = new AliMUONRegHeader();
60 fLocalStruct = new AliMUONLocalStruct();
64 //_________________________________________________________________
65 AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(AliRawReader* rawReader)
75 // ctor with AliRawReader as argument
76 // for reconstruction purpose
79 fRawReader = rawReader;
81 fDDLTrigger = new AliMUONDDLTrigger();
82 fRegHeader = new AliMUONRegHeader();
83 fLocalStruct = new AliMUONLocalStruct();
87 //_________________________________________________________________
88 AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(const AliMUONRawStreamTrigger& stream) :
94 AliFatal("copy constructor not implemented");
97 //______________________________________________________________________
98 AliMUONRawStreamTrigger& AliMUONRawStreamTrigger::operator = (const AliMUONRawStreamTrigger&
102 // assignment operator
104 AliFatal("assignment operator not implemented");
108 //___________________________________
109 AliMUONRawStreamTrigger::~AliMUONRawStreamTrigger()
119 //_____________________________________________________________
120 Bool_t AliMUONRawStreamTrigger::Next()
122 // read the next raw digit (buspatch structure)
123 // returns kFALSE if there is no digit left
126 // if(!NextDDL()) return kFALSE;
128 // Int_t nEntries = fDDLTrigger->GetBusPatchEntries();
130 // if (fSubEntries < nEntries) {
131 // fLocalStruct = (AliMUONLocalStruct*)fDDLTrigger->GetBusPatchEntry(fSubEntries);
133 // fNextDDL = kFALSE;
136 // fDDLTrigger->GetBusPatchArray()->Delete();
145 //______________________________________________________
146 Bool_t AliMUONRawStreamTrigger::NextDDL()
148 // reading tracker DDL
149 // store buspatch info into Array
150 // store only non-empty structures (buspatch info with datalength !=0)
152 // reading DDL for trigger
154 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
156 Int_t kDarcHeaderSize = darcHeader->GetHeaderLength();
157 Int_t kRegHeaderSize = fRegHeader->GetHeaderLength() ;
158 Bool_t scalerEvent = kFALSE;
161 darcHeader->GetRegHeaderArray()->Delete();
162 //darcHeader->GetRegHeaderArray()->Clear("C");
164 // loop over the two ddl's
165 if (fDDL >= fMaxDDL) {
171 fRawReader->Select(0XA,fDDL,fDDL); //Select the DDL file to be read
173 fRawReader->ReadHeader();
175 Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
176 UInt_t *buffer = new UInt_t[totalDataWord/4];
178 fRawReader->ReadNext((UChar_t*)buffer, totalDataWord);
181 darcHeader->SetWord(buffer[index++]);
183 if(darcHeader->GetEventType() == 2) {
186 scalerEvent = kFALSE;
189 // 6 DARC scaler words
190 memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
191 index += darcHeader->GetDarcScalerLength();
194 if (buffer[index++] != darcHeader->GetEndOfDarc())
195 AliWarning(Form("Wrong end of Darc word %d instead of %d\n",buffer[index-1], darcHeader->GetEndOfDarc()));
197 // 4 words of global board input + Global board output
198 memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kDarcHeaderSize-1)*4);
199 index += kDarcHeaderSize- 1; // kind tricky cos scaler info in-between Darc header
202 // 10 Global scaler words
203 memcpy(darcHeader->GetGlobalScalers(), &buffer[index], darcHeader->GetGlobalScalerLength()*4);
204 index += darcHeader->GetGlobalScalerLength();
207 if (buffer[index++] != darcHeader->GetEndOfGlobal())
208 AliWarning(Form("Wrong end of Global word %d instead of %d\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
211 for (Int_t iReg = 0; iReg < fMaxReg; iReg++) { //loop over regeonal card
213 memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
214 index += kRegHeaderSize;
216 fDDLTrigger->AddRegHeader(*fRegHeader);
217 // 11 regional scaler word
219 memcpy(fRegHeader->GetScalers(), &buffer[index], fRegHeader->GetScalerLength()*4);
220 index += fRegHeader->GetScalerLength();
223 if (buffer[index++] != fRegHeader->GetEndOfReg())
224 AliWarning(Form("Wrong end of Reg word %d instead of %d\n",buffer[index-1], fRegHeader->GetEndOfReg()));
226 // 16 local cards per regional board
227 for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) { //loop over local card
229 Int_t dataSize = fLocalStruct->GetLength();;
231 // 5 word trigger information
232 memcpy(fLocalStruct->GetData(), &buffer[index], dataSize*4);
235 // 45 regional scaler word
237 memcpy(fLocalStruct->GetScalers(), &buffer[index], fLocalStruct->GetScalerLength()*4);
238 index += fLocalStruct->GetScalerLength();
241 if (buffer[index++] != fLocalStruct->GetEndOfLocal())
242 AliWarning(Form("Wrong end of local word %d instead of %d\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
244 fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
248 } // regional card loop
258 //______________________________________________________
259 void AliMUONRawStreamTrigger::ResetDDL()
261 // reseting TClonesArray
264 AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
265 darcHeader->GetRegHeaderArray()->Clear("C");
268 //______________________________________________________
269 void AliMUONRawStreamTrigger::SetMaxDDL(Int_t ddl)
272 if (ddl > 2) ddl = 2;
276 //______________________________________________________
277 void AliMUONRawStreamTrigger::SetMaxReg(Int_t reg)
279 // set regional card number
280 if (reg > 8) reg = 8;
284 //______________________________________________________
285 void AliMUONRawStreamTrigger::SetMaxLoc(Int_t loc)
287 // set local card number
288 if (loc > 16) loc = 16;