]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCDigitReaderDecoder.cxx
Digits marked according to pad status
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReaderDecoder.cxx
CommitLineData
7e914051 1// $Id$
f8121cb1 2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
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. *
11//* *
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//**************************************************************************
20
21/** @file AliHLTTPCDigitReaderDecoder.cxx
22 @author Kenneth Aamodt, Matthias Richter
23 @date
24 @brief DigitReader implementation for the fast ALTRO Decoder
25*/
26
27#if __GNUC__>= 3
28using namespace std;
29#endif
30
7c9a4e09 31#include <cassert>
f8121cb1 32#include "AliHLTTPCDigitReaderDecoder.h"
7dceaa9b 33#include "AliHLTTPCMapping.h"
f8121cb1 34#include "AliAltroDecoder.h"
35#include "AliAltroData.h"
36#include "AliAltroBunch.h"
37
38ClassImp(AliHLTTPCDigitReaderDecoder)
39
40AliHLTTPCDigitReaderDecoder::AliHLTTPCDigitReaderDecoder()
41 :
7dceaa9b 42 AliHLTTPCDigitReader(),
43 fAltroDecoder(NULL),
44 fAltroData(),
45 fAltroBunch(NULL),
46 fMapping(NULL),
7c9a4e09 47 // initialization due to the logic in NextSignals
48 fNextCounter(-1),
7dceaa9b 49 fNextSignalMethodUsed(kFALSE)
f8121cb1 50{
51 // see header file for class documentation
52 // or
53 // refer to README to build package
54 // or
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
56}
57
58AliHLTTPCDigitReaderDecoder::~AliHLTTPCDigitReaderDecoder()
59{
60 // see header file for class documentation
7dceaa9b 61 if(fAltroDecoder){
62 delete fAltroDecoder;
63 }
64 if(fAltroBunch){
65 delete fAltroBunch;
66 }
67 if(fMapping){
68 delete fMapping;
69 }
f8121cb1 70}
71
a74855c2 72int AliHLTTPCDigitReaderDecoder::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t /*slice*/)
f8121cb1 73{
74 // see header file for class documentation
7c9a4e09 75 // HLTDebug("Initializing block in decoder");
76 if(!fMapping){
77 fMapping = new AliHLTTPCMapping(patch);
78 }
79 if(!fAltroDecoder){
80 fAltroDecoder = new AliAltroDecoder();
81 }
82 if(!fAltroBunch){
83 fAltroBunch = new AliAltroBunch();
84 }
7dceaa9b 85 fAltroDecoder->SetMemory((UChar_t*)ptr, size);
86 fAltroDecoder->Decode();
f8121cb1 87 return 0;
88}
89
90bool AliHLTTPCDigitReaderDecoder::NextChannel()
91{
92 // see header file for class documentation
7dceaa9b 93 return fAltroDecoder->NextChannel(&fAltroData);
f8121cb1 94}
95
96int AliHLTTPCDigitReaderDecoder::NextBunch()
97{
98 // see header file for class documentation
7dceaa9b 99 return fAltroData.NextBunch(fAltroBunch);
f8121cb1 100}
101
102bool AliHLTTPCDigitReaderDecoder::NextSignal()
103{
104 // see header file for class documentation
7c9a4e09 105 fNextSignalMethodUsed=kTRUE;
106 do {
107 if (fNextCounter>0) {
108 // there is data available in the current bunch
109 fNextCounter--;
110 return true;
7dceaa9b 111 }
7c9a4e09 112
113 // there is no data left in the current bunch, search for the next one
114 while (NextBunch()) if (GetBunchSize()>0) {
115 fNextCounter=GetBunchSize()-1;
116 return true;
7dceaa9b 117 }
7c9a4e09 118
119 fNextCounter=-1;
120 // there is no bunch left, go to the next channel
121 } while (NextChannel());
7dceaa9b 122
7c9a4e09 123 return false;
f8121cb1 124}
125
7dceaa9b 126const UInt_t* AliHLTTPCDigitReaderDecoder::GetSignals()
f8121cb1 127{
128 // see header file for class documentation
7dceaa9b 129 return fAltroBunch->GetData();
f8121cb1 130}
131
132int AliHLTTPCDigitReaderDecoder::GetRow()
133{
134 // see header file for class documentation
7dceaa9b 135 return fMapping->GetRow(fAltroData.GetHadd());
f8121cb1 136}
137
138int AliHLTTPCDigitReaderDecoder::GetPad()
139{
140 // see header file for class documentation
7dceaa9b 141 return fMapping->GetPad(fAltroData.GetHadd());
f8121cb1 142}
143
144int AliHLTTPCDigitReaderDecoder::GetSignal()
145{
146 // see header file for class documentation
7c9a4e09 147 if (fNextSignalMethodUsed) {
148 const UInt_t* pData=GetSignals();
149 if (pData && fNextCounter>=0) {
150 assert(fNextCounter<GetBunchSize());
151 return pData[fNextCounter];
152 }
153 }
f8121cb1 154 return 0;
155}
156
157int AliHLTTPCDigitReaderDecoder::GetTime()
158{
159 // see header file for class documentation
7dceaa9b 160 if(!fNextSignalMethodUsed){// this is true if the bunch approach is used
161 return fAltroBunch->GetStartTimeBin();
162 }
163 else{
7c9a4e09 164 assert(fNextCounter>=0);
7dceaa9b 165 return fAltroBunch->GetStartTimeBin()+fNextCounter;
166 }
167}
168
169int AliHLTTPCDigitReaderDecoder::GetBunchSize()
170{
7c9a4e09 171 // see header file for class documentation
7dceaa9b 172 return fAltroBunch->GetBunchSize();
f8121cb1 173}
7c9a4e09 174
175AliHLTUInt32_t AliHLTTPCDigitReaderDecoder::GetAltroBlockHWaddr() const
176{
177 // see header file for class documentation
178 return (AliHLTUInt32_t)fAltroData.GetHadd();
179}