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 **************************************************************************/
19 ///////////////////////////////////////////////////////////////////////////////
21 /// \class AliMUONRawStreamTracker
22 /// This class provides access to MUON digits in raw data.
24 /// It loops over all MUON digits in the raw data given by the AliRawReader.
25 /// The Next method goes to the next digit. If there are no digits left
26 /// it returns kFALSE (under develpment)
27 /// It can loop also over DDL and store the decoded rawdata in TClonesArray
30 /// Version implement for Tracker
32 /// \author Christian Finck & Laurent Aphecetche
33 ///////////////////////////////////////////////////////////////////////////////
35 #include "AliMUONRawStreamTracker.h"
37 #include "AliRawReader.h"
38 #include "AliRawDataHeader.h"
41 #include "AliMUONPayloadTracker.h"
42 #include "AliMUONBlockHeader.h"
43 #include "AliMUONDspHeader.h"
44 #include "AliMUONBusStruct.h"
45 #include "AliMUONDDLTracker.h"
46 #include "Riostream.h"
49 ClassImp(AliMUONRawStreamTracker)
52 AliMUONRawStreamTracker::AliMUONRawStreamTracker()
57 fPayload(new AliMUONPayloadTracker()),
59 fCurrentDDLIndex(fMaxDDL),
60 fCurrentBlockHeader(0),
61 fCurrentBlockHeaderIndex(0),
63 fCurrentDspHeaderIndex(0),
65 fCurrentBusStructIndex(0),
67 fEnableErrorLogger(kFALSE)
70 /// create an object to read MUON raw digits
71 /// Default ctor for monitoring purposes
77 //_________________________________________________________________
78 AliMUONRawStreamTracker::AliMUONRawStreamTracker(AliRawReader* rawReader)
80 fRawReader(rawReader),
83 fPayload(new AliMUONPayloadTracker()),
85 fCurrentDDLIndex(fMaxDDL),
86 fCurrentBlockHeader(0),
87 fCurrentBlockHeaderIndex(0),
89 fCurrentDspHeaderIndex(0),
91 fCurrentBusStructIndex(0),
93 fEnableErrorLogger(kFALSE)
96 /// ctor with AliRawReader as argument
97 /// for reconstruction purpose
103 //___________________________________
104 AliMUONRawStreamTracker::~AliMUONRawStreamTracker()
112 //_____________________________________________________________
114 AliMUONRawStreamTracker::Next(Int_t& busPatchId,
115 UShort_t& manuId, UChar_t& manuChannel,
119 /// read the next raw digit (buspatch structure)
120 /// returns kFALSE if there is no digit left
123 if ( IsDone() ) return kFALSE;
125 if ( fCurrentDataIndex >= fCurrentBusStruct->GetLength()-1 )
127 Bool_t ok = GetNextBusStruct();
137 busPatchId = fCurrentBusStruct->GetBusPatchId();
138 manuId = fCurrentBusStruct->GetManuId(fCurrentDataIndex);
139 manuChannel = fCurrentBusStruct->GetChannelId(fCurrentDataIndex);
140 adc = fCurrentBusStruct->GetCharge(fCurrentDataIndex);
145 //______________________________________________________
147 AliMUONRawStreamTracker::IsDone() const
149 /// Whether the iteration is finished or not
150 return (fCurrentBusStruct==0);
153 //______________________________________________________
155 AliMUONRawStreamTracker::First()
157 /// Initialize the iteration process
159 fCurrentDDLIndex = -1;
160 fCurrentDspHeaderIndex = -1;
161 fCurrentBusStructIndex = -1;
163 fCurrentDspHeader = 0;
164 fCurrentBusStruct = 0;
166 // Find the first non-empty structure
168 GetNextBlockHeader();
173 //______________________________________________________
175 AliMUONRawStreamTracker::GetNextDDL()
177 /// Returns the next DDL present
179 Bool_t kFound(kFALSE);
181 while ( fCurrentDDLIndex < fMaxDDL-1 && !kFound )
185 fRawReader->Select("MUONTRK",fCurrentDDLIndex,fCurrentDDLIndex);
186 if ( fRawReader->ReadHeader() )
194 fCurrentDDLIndex = fMaxDDL;
198 Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
200 AliDebug(3, Form("DDL Number %d totalDataWord %d\n", fCurrentDDLIndex,
203 UInt_t *buffer = new UInt_t[totalDataWord/4];
205 if ( !fRawReader->ReadNext((UChar_t*)buffer, totalDataWord) )
210 fPayload->ResetDDL();
212 Bool_t ok = fPayload->Decode(buffer, totalDataWord/4);
214 if (fEnableErrorLogger) AddErrorMessage();
218 fCurrentDDL = fPayload->GetDDLTracker();
220 fCurrentBlockHeaderIndex = -1;
225 //______________________________________________________
227 AliMUONRawStreamTracker::GetNextBlockHeader()
229 /// Returns the next block Header present
231 fCurrentBlockHeader = 0;
233 Int_t i(fCurrentBlockHeaderIndex);
235 while ( fCurrentBlockHeader == 0 && i < fCurrentDDL->GetBlkHeaderEntries()-1 )
238 fCurrentBlockHeader = fCurrentDDL->GetBlkHeaderEntry(i);
241 if ( !fCurrentBlockHeader )
243 Bool_t ok = GetNextDDL();
250 return GetNextBlockHeader();
254 fCurrentBlockHeaderIndex = i;
256 fCurrentDspHeaderIndex = -1;
261 //______________________________________________________
263 AliMUONRawStreamTracker::GetNextDspHeader()
265 /// Returns the next Dsp Header present
267 fCurrentDspHeader = 0;
269 Int_t i(fCurrentDspHeaderIndex);
271 while ( fCurrentDspHeader == 0 && i < fCurrentBlockHeader->GetDspHeaderEntries()-1 )
274 fCurrentDspHeader = fCurrentBlockHeader->GetDspHeaderEntry(i);
277 if ( !fCurrentDspHeader )
279 Bool_t ok = GetNextBlockHeader();
286 return GetNextDspHeader();
290 fCurrentDspHeaderIndex = i;
292 fCurrentBusStructIndex = -1;
297 //______________________________________________________
299 AliMUONRawStreamTracker::GetNextBusStruct()
301 /// Find the next non-empty busPatch structure
303 fCurrentBusStruct = 0;
305 Int_t i(fCurrentBusStructIndex);
307 while ( fCurrentBusStruct == 0 && i < fCurrentDspHeader->GetBusPatchEntries()-1 )
310 fCurrentBusStruct = fCurrentDspHeader->GetBusPatchEntry(i);
313 if ( !fCurrentBusStruct )
315 Bool_t ok = GetNextDspHeader();
322 return GetNextBusStruct();
326 fCurrentBusStructIndex = i;
328 fCurrentDataIndex = -1;
333 //______________________________________________________
334 Bool_t AliMUONRawStreamTracker::NextDDL()
336 /// reading tracker DDL
338 fPayload->ResetDDL();
343 fRawReader->Select("MUONTRK", fDDL, fDDL); //Select the DDL file to be read
344 if (fRawReader->ReadHeader()) break;
345 AliDebug(3,Form("Skipping DDL %d which does not seem to be there",fDDL));
355 AliDebug(3, Form("DDL Number %d\n", fDDL ));
357 Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
359 UInt_t *buffer = new UInt_t[totalDataWord/4];
361 if(!fRawReader->ReadNext((UChar_t*)buffer, totalDataWord))
367 Bool_t ok = fPayload->Decode(buffer, totalDataWord/4);
369 if (fEnableErrorLogger) AddErrorMessage();
378 //______________________________________________________
379 void AliMUONRawStreamTracker::SetMaxDDL(Int_t ddl)
382 if (ddl > 20) ddl = 20;
386 //______________________________________________________
387 void AliMUONRawStreamTracker::SetMaxBlock(Int_t blk)
389 /// set regional card number
390 fPayload->SetMaxBlock(blk);
393 //______________________________________________________
394 void AliMUONRawStreamTracker::AddErrorMessage()
396 /// add message into logger of AliRawReader per event
398 for (Int_t i = 0; i < fPayload->GetParityErrors(); ++i)
399 fRawReader->AddMinorErrorLog(kParityErr, Form("Parity error for buspatch %s",
400 fPayload->GetParityErrBus()[i]));
402 for (Int_t i = 0; i < fPayload->GetGlitchErrors(); ++i)
403 fRawReader->AddMajorErrorLog(kGlitchErr, "Glitch error occurs skip event");
405 for (Int_t i = 0; i < fPayload->GetPaddingErrors(); ++i)
406 fRawReader->AddMinorErrorLog(kPaddingWordErr, "Padding word error");