X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FTPCLib%2FAliHLTTPCDigitReaderDecoder.cxx;h=badf9ee2ba299051b1d62e273725c4479eef607f;hb=4ea087a6331e9a7752cc0cbee465a29c03e0c448;hp=5087cc7588eda9c22ce9f87d10d5e802b5fbc0b7;hpb=900fdfb269d2b4fc184ca63e6fda17e00a3f1481;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx b/HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx index 5087cc7588e..badf9ee2ba2 100644 --- a/HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx +++ b/HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx @@ -56,11 +56,14 @@ AliHLTTPCDigitReaderDecoder::AliHLTTPCDigitReaderDecoder() // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt } +AliAltroDecoder* AliHLTTPCDigitReaderDecoder::fgpFreeInstance=NULL; +AliAltroDecoder* AliHLTTPCDigitReaderDecoder::fgpIssuedInstance=NULL; + AliHLTTPCDigitReaderDecoder::~AliHLTTPCDigitReaderDecoder() { // see header file for class documentation if(fAltroDecoder){ - delete fAltroDecoder; + ReleaseDecoderInstance(fAltroDecoder); } if(fAltroBunch){ delete fAltroBunch; @@ -77,8 +80,9 @@ int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t p if(!fMapping){ fMapping = new AliHLTTPCMapping(patch); } + fAltroDecoder=GetDecoderInstance(); if(!fAltroDecoder){ - fAltroDecoder = new AliAltroDecoder(); + return -ENODEV; } if(!fAltroBunch){ fAltroBunch = new AliAltroBunch(); @@ -88,6 +92,20 @@ int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t p return 0; } +int AliHLTTPCDigitReaderDecoder::Reset() +{ + // see header file for class documentation + fAltroData.Reset(); + fAltroData.SetIsComplete(false); + if (fAltroBunch) { + fAltroBunch->SetBunchSize(0); + fAltroBunch->SetData(NULL); + } + if (fAltroDecoder) ReleaseDecoderInstance(fAltroDecoder); + fAltroDecoder=NULL; + return 0; +} + void AliHLTTPCDigitReaderDecoder::SetUnsorted(bool unsorted) { // see header file for class documentation @@ -100,6 +118,7 @@ void AliHLTTPCDigitReaderDecoder::SetUnsorted(bool unsorted) bool AliHLTTPCDigitReaderDecoder::NextChannel() { // see header file for class documentation + if (!fAltroDecoder) return false; Bool_t result=fAltroDecoder->NextChannel(&fAltroData); if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){ result = fAltroDecoder->NextChannel(&fAltroData); @@ -211,3 +230,58 @@ AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr(Int_t row, Int_t return 0; } } + +int AliHLTTPCDigitReaderDecoder::GetRCUTrailerSize() +{ + // see header file for class documentation + if(fAltroDecoder){ + return fAltroDecoder->GetRCUTrailerSize(); + } + return 0; +} + +bool AliHLTTPCDigitReaderDecoder::GetRCUTrailerData(UChar_t*& trData) +{ + // see header file for class documentation + if(fAltroDecoder){ + return fAltroDecoder->GetRCUTrailerData(trData); + } + return false; +} + +AliAltroDecoder* AliHLTTPCDigitReaderDecoder::GetDecoderInstance() +{ + // see header file for class documentation + + // for the moment only a singleton of the decoder is foreseen + // could be extended but very unlikly to be worth the effort + // because AliAltroDecoder sooner or later will be deprecated. + + // This is just a poor man's solution, no synchronization for the + // moment + if (fgpIssuedInstance) { + AliHLTLogging log; + log.LoggingVarargs(kHLTLogError, "AliHLTTPCDigitReaderDecoder", "GetDecoderInstance" , __FILE__ , __LINE__ , + "instance of AltroDecoder has not been released or multiple instances requested. Only available as global singleton for DigitReaderDecoder"); + return NULL; + } + + if (!fgpFreeInstance) fgpFreeInstance=new AliAltroDecoder; + fgpIssuedInstance=fgpFreeInstance; + fgpFreeInstance=NULL; + return fgpIssuedInstance; +} + +void AliHLTTPCDigitReaderDecoder::ReleaseDecoderInstance(AliAltroDecoder* pInstance) +{ + // see header file for class documentation + if (!pInstance) return; + if (pInstance!=fgpIssuedInstance) { + AliHLTLogging log; + log.LoggingVarargs(kHLTLogError, "AliHLTTPCDigitReaderDecoder", "ReleaseDecoderInstance" , __FILE__ , __LINE__ , + "wrong instance %p, expecting %p", pInstance, fgpIssuedInstance); + return; + } + fgpFreeInstance=fgpIssuedInstance; + fgpIssuedInstance=NULL; +}