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 bool AliHLTTPCDigitReaderDecoder::NextChannel()
93 // see header file for class documentation
94 Bool_t result=fAltroDecoder->NextChannel(&fAltroData);
95 if(result && !fMapping->IsValidHWAddress(fAltroData.GetHadd())){
96 result = fAltroDecoder->NextChannel(&fAltroData);
101 int AliHLTTPCDigitReaderDecoder::NextBunch()
103 // see header file for class documentation
104 return fAltroData.NextBunch(fAltroBunch);
107 bool AliHLTTPCDigitReaderDecoder::NextSignal()
109 // see header file for class documentation
110 fNextSignalMethodUsed=kTRUE;
112 if (fNextCounter>0) {
113 // there is data available in the current bunch
118 // there is no data left in the current bunch, search for the next one
119 while (NextBunch()) if (GetBunchSize()>0) {
120 fNextCounter=GetBunchSize()-1;
125 // there is no bunch left, go to the next channel
126 } while (NextChannel());
131 const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals()
133 // see header file for class documentation
134 return fAltroBunch->GetData();
137 int AliHLTTPCDigitReaderDecoder::GetRow()
139 // see header file for class documentation
140 return fMapping->GetRow(fAltroData.GetHadd());
143 int AliHLTTPCDigitReaderDecoder::GetPad()
145 // see header file for class documentation
146 return fMapping->GetPad(fAltroData.GetHadd());
149 int AliHLTTPCDigitReaderDecoder::GetSignal()
151 // see header file for class documentation
152 if (fNextSignalMethodUsed) {
153 const UInt_t* pData=GetSignals();
154 if (pData && fNextCounter>=0) {
155 assert(fNextCounter<GetBunchSize());
156 return pData[fNextCounter];
162 int AliHLTTPCDigitReaderDecoder::GetTime()
164 // see header file for class documentation
166 if(!fNextSignalMethodUsed){// this is true if the bunch approach is used
168 iResult= fAltroBunch->GetStartTimeBin();
171 assert(fNextCounter>=0);
172 iResult = fAltroBunch->GetStartTimeBin()+fNextCounter;
174 if(iResult<0 || iResult>AliHLTTPCTransform::GetNTimeBins()){
180 int AliHLTTPCDigitReaderDecoder::GetBunchSize()
182 // see header file for class documentation
183 return fAltroBunch->GetBunchSize();
186 int AliHLTTPCDigitReaderDecoder::GetRowOffset() const
188 return fMapping->GetRowOffset();
190 AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const
192 // see header file for class documentation
193 return (AliHLTUInt32_t)fAltroData.GetHadd();
195 AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr(Int_t row, Int_t pad) const
197 // see header file for class documentation
199 return fMapping->GetHwAddress(row,pad);