From 66964465fcca61ba7e034a50bd11e18dd535ceb1 Mon Sep 17 00:00:00 2001 From: cvetan Date: Fri, 17 Jul 2009 13:06:29 +0000 Subject: [PATCH] New method to access certain event number by using also its event-id. Useful in case an event selection/filtering is used. --- RAW/AliRawReader.cxx | 37 ++++++++++++++++++++++++++++++++++--- RAW/AliRawReader.h | 4 ++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/RAW/AliRawReader.cxx b/RAW/AliRawReader.cxx index 1fc4a057698..922958bc4cd 100644 --- a/RAW/AliRawReader.cxx +++ b/RAW/AliRawReader.cxx @@ -541,10 +541,19 @@ Bool_t AliRawReader::ReadNextChar(UChar_t& data) return kTRUE; } -Bool_t AliRawReader::GotoEvent(Int_t /*event*/) +Bool_t AliRawReader::GotoEvent(Int_t event) { - Error("GotoEvent","Method not implemented! Nothing done"); - return kFALSE; + // Random access to certain + // event index. Could be very slow + // for some non-root raw-readers. + // So it should be reimplemented there. + if (event < fEventNumber) RewindEvents(); + + while (fEventNumber < event) { + if (!NextEvent()) return kFALSE; + } + + return kTRUE; } Int_t AliRawReader::CheckData() const @@ -701,3 +710,25 @@ void AliRawReader::AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level, if (prevLog) prevLog->AddCount(); } + +Bool_t AliRawReader::GotoEventWithID(Int_t event, + UInt_t period, + UInt_t orbitID, + UShort_t bcID) +{ + // Go to certain event number by + // checking the event ID. + // Useful in case event-selection + // is applied and the 'event' is + // relative + if (!GotoEvent(event)) return kFALSE; + + while (GetBCID() != period || + GetOrbitID() != orbitID || + GetPeriod() != bcID) { + if (!NextEvent()) return kFALSE; + } + + return kTRUE; +} + diff --git a/RAW/AliRawReader.h b/RAW/AliRawReader.h index 6ed347e4015..85cdfa54163 100644 --- a/RAW/AliRawReader.h +++ b/RAW/AliRawReader.h @@ -123,6 +123,10 @@ class AliRawReader: public TObject { virtual Bool_t NextEvent() = 0; virtual Bool_t RewindEvents() = 0; virtual Bool_t GotoEvent(Int_t event); + virtual Bool_t GotoEventWithID(Int_t event, + UInt_t period, + UInt_t orbitID, + UShort_t bcID); virtual Int_t GetEventIndex() const { return -1; } virtual Int_t GetNumberOfEvents() const { return -1; } -- 2.39.3