+ /// Whether the iteration is finished or not
+ return (fCurrentLocalStruct==0);
+}
+
+//______________________________________________________
+void AliMUONRawStreamTrigger::First()
+{
+ /// Initialize the iteration process.
+
+ fCurrentDDLIndex = -1;
+ // Must reset all the pointers because if we return before calling
+ // GetNextLocalStruct() the user might call CurrentDDL(), CurrentBlockHeader(),
+ // CurrentRegHeader() or CurrentLocalStruct() which should return reasonable
+ // results in that case.
+ fCurrentDDL = 0;
+ fCurrentDarcHeader = 0;
+ fCurrentRegHeader = 0;
+ fCurrentLocalStruct = 0;
+
+ // Find the first non-empty structure
+ if (not GetNextDDL()) return;
+ if (not GetNextRegHeader()) return;
+ GetNextLocalStruct();
+}
+
+//______________________________________________________
+Bool_t AliMUONRawStreamTrigger::GetNextDDL()
+{
+ /// Returns the next DDL present
+
+ assert( GetReader() != 0 );
+
+
+ Bool_t kFound(kFALSE);
+
+ while ( fCurrentDDLIndex < fgkMaxDDL-1 && !kFound )
+ {
+ ++fCurrentDDLIndex;
+ GetReader()->Reset();
+ GetReader()->Select("MUONTRG",fCurrentDDLIndex,fCurrentDDLIndex);
+ if ( GetReader()->ReadHeader() )
+ {
+ kFound = kTRUE;
+ }
+ }
+
+ if ( !kFound )
+ {
+ // 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 = GetReader()->GetDataSize(); // in bytes
+
+ Bool_t scalerEvent = GetReader()->GetDataHeader()->GetL1TriggerMessage() & 0x1;
+
+ AliDebug(3, Form("DDL Number %d totalDataWord %d\n", fCurrentDDLIndex,
+ totalDataWord));
+
+ UInt_t *buffer = new UInt_t[totalDataWord/4];
+
+ if ( !GetReader()->ReadNext((UChar_t*)buffer, totalDataWord) )
+ {
+ // 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;
+ }
+
+#ifndef R__BYTESWAP
+ Swap(buffer, totalDataWord / sizeof(UInt_t)); // swap needed for mac power pc
+#endif
+
+ fPayload->ResetDDL();
+
+
+
+ Bool_t ok = fPayload->Decode(buffer, scalerEvent);
+
+ delete[] buffer;
+
+ fCurrentDDL = fPayload->GetDDLTrigger();
+
+ fCurrentDarcHeader = fCurrentDDL->GetDarcHeader();
+
+ fCurrentRegHeaderIndex = -1;
+
+
+ return ok;
+}
+
+
+//______________________________________________________
+Bool_t AliMUONRawStreamTrigger::GetNextRegHeader()
+{
+ /// Returns the next Reg Header present
+
+ assert( fCurrentDarcHeader != 0 );
+ assert( fCurrentDDL != 0 );
+
+ fCurrentRegHeader = 0;
+
+ Int_t i = fCurrentRegHeaderIndex;
+
+ while ( fCurrentRegHeader == 0 && i < fCurrentDarcHeader->GetRegHeaderEntries()-1 )
+ {
+ ++i;
+ fCurrentRegHeader = fCurrentDarcHeader->GetRegHeaderEntry(i);
+ }
+
+ if ( !fCurrentRegHeader )
+ {
+ Bool_t ok = GetNextDDL();
+ if (!ok)
+ {
+ return kFALSE;
+ }
+ else
+ {
+ return GetNextRegHeader();
+ }
+ }
+
+ fCurrentRegHeaderIndex = i;
+
+ fCurrentLocalStructIndex = -1;
+
+ return kTRUE;
+}
+
+//______________________________________________________
+Bool_t AliMUONRawStreamTrigger::GetNextLocalStruct()
+{
+ /// Find the next non-empty local structure
+
+ assert( fCurrentRegHeader != 0 );
+
+ fCurrentLocalStruct = 0;
+
+ Int_t i = fCurrentLocalStructIndex;
+
+ while ( fCurrentLocalStruct == 0 && i < fCurrentRegHeader->GetLocalEntries()-1 )
+ {
+ ++i;
+ fCurrentLocalStruct = fCurrentRegHeader->GetLocalEntry(i);
+ }
+
+ if ( !fCurrentLocalStruct )
+ {
+ Bool_t ok = GetNextRegHeader();
+ if (!ok)
+ {
+ return kFALSE;
+ }
+ else
+ {
+ return GetNextLocalStruct();
+ }
+ }
+
+ fCurrentLocalStructIndex = i;
+
+ fLocalStructRead = kFALSE;
+
+ return kTRUE;