]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCDigitReader.cxx
commit from Kenneth:
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCDigitReader.cxx
1 // $Id$
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   AliHLTTPCDigitReader.cxx
22     @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt
23     @date   
24     @brief  An abstract reader class for TPC data.
25 */
26
27 #if __GNUC__>= 3
28 using namespace std;
29 #endif
30
31 #include "AliHLTTPCDigitReader.h"
32 #include "AliHLTTPCTransform.h"
33 #include "AliHLTStdIncludes.h"
34
35 ClassImp(AliHLTTPCDigitReader)
36
37 AliHLTTPCDigitReader::AliHLTTPCDigitReader()
38   :
39   fFlags(0),
40   fLckRow(-1),
41   fLckPad(-1)
42 {
43 }
44
45 AliHLTTPCDigitReader::~AliHLTTPCDigitReader()
46 {
47 }
48
49 int AliHLTTPCDigitReader::InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice)
50 {
51   if (patch<0 || patch>=AliHLTTPCTransform::GetNumberOfPatches()) {
52     HLTError("invalid readout partition number %d", patch);
53     return -EINVAL;
54   }
55   if (firstrow!=AliHLTTPCTransform::GetFirstRow(patch)) {
56     HLTWarning("The firstrow parameter does not match the layout of the readout partition %d "
57                "(firstrow=%d). Parameter is ignored", patch, AliHLTTPCTransform::GetFirstRow(patch));
58   }
59   if (lastrow!=AliHLTTPCTransform::GetLastRow(patch)) {
60     HLTWarning("The lastrow parameter does not match the layout of the readout partition %d "
61                "(lastrow=%d). Parameter is ignored", patch, AliHLTTPCTransform::GetLastRow(patch));
62   }
63   return InitBlock(ptr, size, patch, slice);
64 }
65
66 void AliHLTTPCDigitReader::SetOldRCUFormat(Bool_t /*oldrcuformat*/)
67 {
68 }
69 void AliHLTTPCDigitReader::SetUnsorted(Bool_t /*unsorted*/){
70 }
71
72 bool AliHLTTPCDigitReader::Next()
73 {
74   if (!CheckFlag(kLocked)) return NextSignal();
75
76   bool haveData=false;
77   if (!CheckFlag(kChannelOverwrap))
78     haveData=NextSignal();
79
80   if (haveData && (fLckRow!=GetRow() || fLckPad!=GetPad())) {
81     SetFlag(kChannelOverwrap);
82     haveData=false;
83   }
84
85   return haveData;
86 }
87
88 void AliHLTTPCDigitReader::EnableCaching(bool bCache)
89 {
90   if (bCache) SetFlag(kChannelCaching);
91   else ClearFlag(kChannelCaching);
92 }
93
94 int AliHLTTPCDigitReader::RewindChannel()
95 {
96   int iResult=0;
97   
98   return iResult;
99 }
100
101 unsigned int AliHLTTPCDigitReader::SetFlag(unsigned int flag)
102 {
103   return fFlags|=flag;
104 }
105         
106 unsigned int AliHLTTPCDigitReader::ClearFlag(unsigned int flag)
107 {
108   return fFlags&=~flag;
109 }
110
111 // int operator[](int timebin)
112 // {
113 //   return -1;
114 // }
115
116 int AliHLTTPCDigitReader::RewindCurrentChannel()
117 {
118   SetFlag(kNoRewind);
119   if (!CheckFlag(kChannelCaching)) return -ENODATA;
120   return -ENOSYS;
121 }
122
123 int AliHLTTPCDigitReader::RewindToPrevChannel()
124 {
125   SetFlag(kNoRewind);
126   if (!CheckFlag(kChannelCaching)) return -ENODATA;
127   return -ENOSYS;
128 }