3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 //* Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
10 //* for The ALICE HLT Project. *
12 //* Permission to use, copy, modify and distribute this software and its *
13 //* documentation strictly for non-commercial purposes is hereby granted *
14 //* without fee, provided that the above copyright notice appears in all *
15 //* copies and that both the copyright notice and this permission notice *
16 //* appear in the supporting documentation. The authors make no claims *
17 //* about the suitability of this software for any purpose. It is *
18 //* provided "as is" without express or implied warranty. *
19 //**************************************************************************
21 /** @file AliHLTTPCDigitReaderDecoder.cxx
22 @author Kenneth Aamodt, Matthias Richter
24 @brief DigitReader implementation for the fast ALTRO Decoder
32 #include "AliHLTTPCDigitReaderDecoder.h"
33 #include "AliHLTTPCMapping.h"
34 #include "AliAltroDecoder.h"
35 #include "AliAltroData.h"
36 #include "AliAltroBunch.h"
37 #include "AliHLTTPCTransform.h"
39 ClassImp(AliHLTTPCDigitReaderDecoder)
41 AliHLTTPCDigitReaderDecoder::AliHLTTPCDigitReaderDecoder()
43 AliHLTTPCDigitReader(),
48 // initialization due to the logic in NextSignals
50 fNextSignalMethodUsed(kFALSE)
52 // see header file for class documentation
54 // refer to README to build package
56 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59 AliHLTTPCDigitReaderDecoder::~AliHLTTPCDigitReaderDecoder()
61 // see header file for class documentation
73 int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t /*slice*/)
75 // see header file for class documentation
76 // HLTDebug("Initializing block in decoder");
78 fMapping = new AliHLTTPCMapping(patch);
81 fAltroDecoder = new AliAltroDecoder();
84 fAltroBunch = new AliAltroBunch();
86 fAltroDecoder->SetMemory((UChar_t*)ptr, size);
87 fAltroDecoder->Decode();
91 void AliHLTTPCDigitReaderDecoder::SetUnsorted(bool unsorted)
93 // see header file for class documentation
95 // The DigitReaderDecoder does not support sorted data, forward to
96 // default if sorted data requested
97 if (!unsorted) AliHLTTPCDigitReader::SetUnsorted(unsorted);
100 bool AliHLTTPCDigitReaderDecoder::NextChannel()
102 // see header file for class documentation
103 Bool_t result=fAltroDecoder->NextChannel(&fAltroData);
104 if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){
105 result = fAltroDecoder->NextChannel(&fAltroData);
110 int AliHLTTPCDigitReaderDecoder::NextBunch()
112 // see header file for class documentation
113 return fAltroData.NextBunch(fAltroBunch);
116 bool AliHLTTPCDigitReaderDecoder::NextSignal()
118 // see header file for class documentation
119 fNextSignalMethodUsed=kTRUE;
121 if (fNextCounter>0) {
122 // there is data available in the current bunch
127 // there is no data left in the current bunch, search for the next one
128 while (NextBunch()) if (GetBunchSize()>0) {
129 fNextCounter=GetBunchSize()-1;
134 // there is no bunch left, go to the next channel
135 } while (NextChannel());
140 const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals()
142 // see header file for class documentation
143 return fAltroBunch->GetData();
146 int AliHLTTPCDigitReaderDecoder::GetRow()
148 // see header file for class documentation
149 return fMapping->GetRow(fAltroData.GetHadd());
152 int AliHLTTPCDigitReaderDecoder::GetPad()
154 // see header file for class documentation
155 return fMapping->GetPad(fAltroData.GetHadd());
158 int AliHLTTPCDigitReaderDecoder::GetSignal()
160 // see header file for class documentation
161 if (fNextSignalMethodUsed) {
162 const UInt_t* pData=GetSignals();
163 if (pData && fNextCounter>=0) {
164 assert(fNextCounter<GetBunchSize());
165 return pData[fNextCounter];
171 int AliHLTTPCDigitReaderDecoder::GetTime()
173 // see header file for class documentation
175 if(!fNextSignalMethodUsed){// this is true if the bunch approach is used
177 iResult= fAltroBunch->GetStartTimeBin();
180 assert(fNextCounter>=0);
181 iResult = fAltroBunch->GetStartTimeBin()+fNextCounter;
183 if(iResult<0 || iResult>AliHLTTPCTransform::GetNTimeBins()){
189 int AliHLTTPCDigitReaderDecoder::GetBunchSize()
191 // see header file for class documentation
192 return fAltroBunch->GetBunchSize();
195 int AliHLTTPCDigitReaderDecoder::GetRowOffset() const
197 return fMapping->GetRowOffset();
199 AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const
201 // see header file for class documentation
202 return (AliHLTUInt32_t)fAltroData.GetHadd();
204 AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr(Int_t row, Int_t pad) const
206 // see header file for class documentation
208 return fMapping->GetHwAddress(row,pad);