* provided "as is" without express or implied warranty. *
**************************************************************************/
-/* $Id $ */
+/* $Id$ */
-///////////////////////////////////////////////////////////////////////////////
-///
+//-----------------------------------------------------------------------------
/// \class AliMUONRawStreamTracker
/// This class provides access to MUON digits in raw data.
///
/// It loops over all MUON digits in the raw data given by the AliRawReader.
/// The Next method goes to the next digit. If there are no digits left
-/// it returns kFALSE (under develpment)
+/// it returns kFALSE
/// It can loop also over DDL and store the decoded rawdata in TClonesArray
/// in Payload class.
///
-/// Version implement for Tracker
+/// Implement for Tracker
///
/// \author Christian Finck & Laurent Aphecetche
-///////////////////////////////////////////////////////////////////////////////
+//-----------------------------------------------------------------------------
#include "AliMUONRawStreamTracker.h"
+#include "AliMUONLogger.h"
#include "AliRawReader.h"
#include "AliRawDataHeader.h"
#include "AliDAQ.h"
#include "AliMUONBusStruct.h"
#include "AliMUONDDLTracker.h"
#include "Riostream.h"
+#include <cassert>
/// \cond CLASSIMP
ClassImp(AliMUONRawStreamTracker)
/// \endcond
+const Int_t AliMUONRawStreamTracker::fgkMaxDDL = 20;
+
+
+//___________________________________________
AliMUONRawStreamTracker::AliMUONRawStreamTracker()
-: TObject(),
- fRawReader(0x0),
- fDDL(0),
- fMaxDDL(20),
- fPayload(new AliMUONPayloadTracker()),
- fCurrentDDL(0),
- fCurrentDDLIndex(fMaxDDL),
- fCurrentBlockHeader(0),
- fCurrentBlockHeaderIndex(0),
- fCurrentDspHeader(0),
- fCurrentDspHeaderIndex(0),
- fCurrentBusStruct(0),
- fCurrentBusStructIndex(0),
- fCurrentDataIndex(0),
- fEnableErrorLogger(kFALSE)
+ : AliMUONVRawStreamTracker(),
+ fPayload(new AliMUONPayloadTracker()),
+ fCurrentDDL(0),
+ fCurrentDDLIndex(fgkMaxDDL),
+ fCurrentBlockHeader(0),
+ fCurrentBlockHeaderIndex(0),
+ fCurrentDspHeader(0),
+ fCurrentDspHeaderIndex(0),
+ fCurrentBusStruct(0),
+ fCurrentBusStructIndex(0),
+ fCurrentDataIndex(0),
+ fDDL(0)
{
///
/// create an object to read MUON raw digits
//_________________________________________________________________
AliMUONRawStreamTracker::AliMUONRawStreamTracker(AliRawReader* rawReader)
-: TObject(),
- fRawReader(rawReader),
- fDDL(0),
- fMaxDDL(20),
+: AliMUONVRawStreamTracker(rawReader),
fPayload(new AliMUONPayloadTracker()),
- fCurrentDDL(0L),
- fCurrentDDLIndex(fMaxDDL),
+ fCurrentDDL(0),
+ fCurrentDDLIndex(fgkMaxDDL),
fCurrentBlockHeader(0),
fCurrentBlockHeaderIndex(0),
fCurrentDspHeader(0),
fCurrentBusStruct(0),
fCurrentBusStructIndex(0),
fCurrentDataIndex(0),
- fEnableErrorLogger(kFALSE)
+ fDDL(0)
{
///
/// ctor with AliRawReader as argument
///
/// read the next raw digit (buspatch structure)
/// returns kFALSE if there is no digit left
+ /// Should call First() before this method to start the iteration.
///
if ( IsDone() ) return kFALSE;
void
AliMUONRawStreamTracker::First()
{
- /// Initialize the iteration process
+ /// Initialize the iteration process.
fCurrentDDLIndex = -1;
- fCurrentDspHeaderIndex = -1;
- fCurrentBusStructIndex = -1;
-
+// fCurrentDspHeaderIndex = -1; // Not necessary since this gets reset in the GetNextXXX methods.
+// fCurrentBusStructIndex = -1;
+
+ // Must reset all the pointers because if we return before calling
+ // GetNextBusStruct() the user might call CurrentDDL(), CurrentBlockHeader(),
+ // CurrentDspHeader() or CurrentBusStruct() which should return reasonable
+ // results in that case.
+ fCurrentDDL = 0;
+ fCurrentBlockHeader = 0;
fCurrentDspHeader = 0;
fCurrentBusStruct = 0;
// Find the first non-empty structure
- GetNextDDL();
- GetNextBlockHeader();
- GetNextDspHeader();
+ if (not GetNextDDL()) return;
+ if (not GetNextBlockHeader()) return;
+ if (not GetNextDspHeader()) return;
GetNextBusStruct();
}
{
/// Returns the next DDL present
+ assert( GetReader() != 0 );
+
Bool_t kFound(kFALSE);
- while ( fCurrentDDLIndex < fMaxDDL-1 && !kFound )
+ while ( fCurrentDDLIndex < fgkMaxDDL-1 && !kFound )
{
++fCurrentDDLIndex;
- fRawReader->Reset();
- fRawReader->Select("MUONTRK",fCurrentDDLIndex,fCurrentDDLIndex);
- if ( fRawReader->ReadHeader() )
+ GetReader()->Reset();
+ GetReader()->Select("MUONTRK",fCurrentDDLIndex,fCurrentDDLIndex);
+ if ( GetReader()->ReadHeader() )
{
kFound = kTRUE;
}
if ( !kFound )
{
- fCurrentDDLIndex = fMaxDDL;
+ // fCurrentDDLIndex is set to fgkMaxDDL so that we exit the above loop immediately
+ // for a subsequent call to this method, unless NextEvent is called in between.
+ fCurrentDDLIndex = fgkMaxDDL;
+ // We have not actually been able to complete the loading of the new DDL so
+ // we are still on the old one. In this case we do not need to reset fCurrentDDL.
+ //fCurrentDDL = 0;
+ if (IsErrorLogger()) AddErrorMessage();
return kFALSE;
}
- Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
+ Int_t totalDataWord = GetReader()->GetDataSize(); // in bytes
AliDebug(3, Form("DDL Number %d totalDataWord %d\n", fCurrentDDLIndex,
totalDataWord));
-
+
UInt_t *buffer = new UInt_t[totalDataWord/4];
- if ( !fRawReader->ReadNext((UChar_t*)buffer, totalDataWord) )
+ if ( !GetReader()->ReadNext((UChar_t*)buffer, totalDataWord) )
{
- fCurrentDDL = 0;
+ // We have not actually been able to complete the loading of the new DDL so
+ // we are still on the old one. In this case we do not need to reset fCurrentDDL.
+ //fCurrentDDL = 0;
+ delete [] buffer;
return kFALSE;
}
fPayload->ResetDDL();
+#ifndef R__BYTESWAP
+ Swap(buffer, totalDataWord / sizeof(UInt_t)); // swap needed for mac power pc
+#endif
+
Bool_t ok = fPayload->Decode(buffer, totalDataWord/4);
- if (fEnableErrorLogger) AddErrorMessage();
-
delete[] buffer;
fCurrentDDL = fPayload->GetDDLTracker();
AliMUONRawStreamTracker::GetNextBlockHeader()
{
/// Returns the next block Header present
+
+ assert( fCurrentDDL != 0 );
fCurrentBlockHeader = 0;
{
/// Returns the next Dsp Header present
+ assert( fCurrentBlockHeader != 0 );
+
fCurrentDspHeader = 0;
Int_t i(fCurrentDspHeaderIndex);
{
/// Find the next non-empty busPatch structure
+ assert( fCurrentDspHeader != 0 );
+
fCurrentBusStruct = 0;
Int_t i(fCurrentBusStructIndex);
{
/// reading tracker DDL
+ assert( GetReader() != 0 );
+
fPayload->ResetDDL();
- while ( fDDL < 20 )
+ while ( fDDL < fgkMaxDDL )
{
- fRawReader->Reset();
- fRawReader->Select("MUONTRK", fDDL, fDDL); //Select the DDL file to be read
- if (fRawReader->ReadHeader()) break;
+ GetReader()->Reset();
+ GetReader()->Select("MUONTRK", fDDL, fDDL); //Select the DDL file to be read
+ if (GetReader()->ReadHeader()) break;
AliDebug(3,Form("Skipping DDL %d which does not seem to be there",fDDL));
++fDDL;
}
- if ( fDDL == 20 )
+ if ( fDDL == fgkMaxDDL )
{
fDDL = 0;
+ if ( IsErrorLogger()) AddErrorMessage();
return kFALSE;
}
AliDebug(3, Form("DDL Number %d\n", fDDL ));
- Int_t totalDataWord = fRawReader->GetDataSize(); // in bytes
+ Int_t totalDataWord = GetReader()->GetDataSize(); // in bytes
UInt_t *buffer = new UInt_t[totalDataWord/4];
-
- if(!fRawReader->ReadNext((UChar_t*)buffer, totalDataWord))
+
+ if(!GetReader()->ReadNext((UChar_t*)buffer, totalDataWord))
{
delete[] buffer;
return kFALSE;
}
+
+#ifndef R__BYTESWAP
+ Swap(buffer, totalDataWord / sizeof(UInt_t)); // swap needed for mac power pc
+#endif
Bool_t ok = fPayload->Decode(buffer, totalDataWord/4);
- if (fEnableErrorLogger) AddErrorMessage();
-
delete[] buffer;
fDDL++;
return ok;
}
-//______________________________________________________
-void AliMUONRawStreamTracker::SetMaxDDL(Int_t ddl)
-{
- /// set DDL number
- if (ddl > 20) ddl = 20;
- fMaxDDL = ddl;
-}
-
//______________________________________________________
void AliMUONRawStreamTracker::SetMaxBlock(Int_t blk)
{
//______________________________________________________
void AliMUONRawStreamTracker::AddErrorMessage()
{
-/// add message into logger of AliRawReader per event
-
- for (Int_t i = 0; i < fPayload->GetParityErrors(); ++i)
- fRawReader->AddMinorErrorLog(kParityErr, Form("Parity error for buspatch %s",
- fPayload->GetParityErrBus()[i]));
+ /// add message into logger of AliRawReader per event
- for (Int_t i = 0; i < fPayload->GetGlitchErrors(); ++i)
- fRawReader->AddMajorErrorLog(kGlitchErr, "Glitch error occurs skip event");
+ assert( GetReader() != 0 );
+ TString msg;
+ Int_t occurance = 0;
+ AliMUONLogger* log = fPayload->GetErrorLogger();
+
+ log->ResetItr();
+ while(log->Next(msg, occurance))
+ {
+ if (msg.Contains("Parity"))
+ GetReader()->AddMinorErrorLog(kParityErr, msg.Data());
- for (Int_t i = 0; i < fPayload->GetPaddingErrors(); ++i)
- fRawReader->AddMinorErrorLog(kPaddingWordErr, "Padding word error");
+ if (msg.Contains("Glitch"))
+ GetReader()->AddMajorErrorLog(kGlitchErr, msg.Data());
+ if (msg.Contains("Padding"))
+ GetReader()->AddMinorErrorLog(kPaddingWordErr, msg.Data());
+ }
+
+ log->Clear(); // clear logger after each event
}
+
+//______________________________________________________
+Bool_t AliMUONRawStreamTracker::IsErrorMessage() const
+{
+ /// true if there is any error/warning
+ if (GetPayLoad()->GetParityErrors() ||
+ GetPayLoad()->GetGlitchErrors() ||
+ GetPayLoad()->GetPaddingErrors())
+ return kTRUE;
+
+ return kFALSE;
+}
+
+
+
+
+