]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/ITS/AliHLTITSCompressRawDataSDDComponent.cxx
- replaced TTree with TClonesArray for storing clusters (Gaute)
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSCompressRawDataSDDComponent.cxx
CommitLineData
d15fb21a 1// $Id$
0c7d42ab 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: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19/** @file AliHLTITSCompressRawDataSDDComponent.cxx
20 @author Jochen Thaeder <thaeder@kip.uni-heidelberg.de>
21 @date
22 @brief Component to run data compression for SDD
23*/
24
25#if __GNUC__>= 3
26using namespace std;
27#endif
28
29
30#include "AliHLTITSCompressRawDataSDDComponent.h"
31
32#include "AliCDBEntry.h"
33#include "AliCDBManager.h"
34
35#include <cstdlib>
36#include <cerrno>
37#include "TString.h"
38#include "TObjString.h"
39#include <sys/time.h>
40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp(AliHLTITSCompressRawDataSDDComponent);
43
44AliHLTITSCompressRawDataSDDComponent::AliHLTITSCompressRawDataSDDComponent()
45 :
46 fDataCompressor(NULL),
47 fRawReader(NULL) {
48 // see header file for class documentation
49 // or
50 // refer to README to build package
51 // or
52 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53}
54
55AliHLTITSCompressRawDataSDDComponent::~AliHLTITSCompressRawDataSDDComponent() {
56 // see header file for class documentation
57}
58
59// Public functions to implement AliHLTComponent's interface.
60// These functions are required for the registration process
61
62const char* AliHLTITSCompressRawDataSDDComponent::GetComponentID()
63{
64 // see header file for class documentation
65
66 return "ITSDataCompressorSDD";
67}
68
69void AliHLTITSCompressRawDataSDDComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
70 // see header file for class documentation
71 list.clear();
72 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITS );
73
74}
75
76AliHLTComponentDataType AliHLTITSCompressRawDataSDDComponent::GetOutputDataType() {
77 // see header file for class documentation
78 return (kAliHLTDataTypeDDLRaw| kAliHLTDataOriginITS);
79}
80
81void AliHLTITSCompressRawDataSDDComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
82 // see header file for class documentation
83
84 constBase = 0;
859fbc05 85 inputMultiplier = 0.3;
0c7d42ab 86}
87
88AliHLTComponent* AliHLTITSCompressRawDataSDDComponent::Spawn() {
89 // see header file for class documentation
90 return new AliHLTITSCompressRawDataSDDComponent();
91}
92
93Int_t AliHLTITSCompressRawDataSDDComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
94 // see header file for class documentation
95
96 if ( fDataCompressor )
97 return EINPROGRESS;
98
99 fDataCompressor = new AliITSCompressRawDataSDD();
100
101 if ( fRawReader )
102 return EINPROGRESS;
103
104 fRawReader = new AliRawReaderMemory();
105
106 return 0;
107}
108
109Int_t AliHLTITSCompressRawDataSDDComponent::DoDeinit() {
110 // see header file for class documentation
111
112 if ( fRawReader )
113 delete fRawReader;
114 fRawReader = NULL;
115
116 if ( fDataCompressor )
117 delete fDataCompressor;
118 fDataCompressor = NULL;
119
120 return 0;
121}
122
123Int_t AliHLTITSCompressRawDataSDDComponent::DoEvent( const AliHLTComponentEventData& evtData,
124 const AliHLTComponentBlockData* blocks,
125 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
126 AliHLTUInt32_t& size,
127 vector<AliHLTComponentBlockData>& outputBlocks ) {
128 // see header file for class documentation
129
130 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
131 size=0;
132 return 0;
133 }
134
135 // -- Iterator over Data Blocks --
136 const AliHLTComponentBlockData* iter = NULL;
137
138 // -- Ptr to output shm region --
139 AliHLTUInt8_t* outShmPtr = outputPtr;
140
141 // -- Initialize out sizes
142 UInt_t offset = 0; // offset of current outblock
143 UInt_t mySize = 0; // out size produced from current block
144 UInt_t totalSize = 0; // total out size of this event
145 UInt_t availSize = 0; // still availible out size for this event
146
147 // -- Loop over blocks
148 for ( ULong_t ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
149
150 iter = blocks+ndx;
151
152 mySize = 0;
153 offset = totalSize;
154 availSize = size - totalSize;
155
156 // -- Debug output of datatype --
157 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
859fbc05 158 evtData.fEventID, evtData.fEventID,
159 DataType2Text(iter->fDataType).c_str(),
160 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD).c_str());
0c7d42ab 161
162 // -- Check for the correct data type
859fbc05 163 if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD) )
0c7d42ab 164 continue;
0c7d42ab 165
166 // -- Set RawReader
167 fRawReader->SetMemory( (UChar_t*) iter->fPtr, iter->fSize );
168
169 // -- Get equipment ID out of specification
170 AliHLTUInt32_t spec = iter->fSpecification;
171
172 Int_t id = 256;
173 for ( Int_t ii = 0; ii < 24 ; ii++ ) {
174 if ( spec & 0x00000001 ) {
175 id += ii;
176 break;
177 }
178 spec = spec >> 1 ;
179 }
180
181 // -- Set equipment ID to the raw reader
182 fRawReader->SetEquipmentID( id );
183
184 // -- Set raw reader
185 fDataCompressor->SetRawReader( fRawReader );
186
187 // -- Set ptr to output shm
188 fDataCompressor->SetPointerToData( (UChar_t*) outShmPtr );
189
190 // -- Set availible outputspace
191 fDataCompressor->SetSize( (UInt_t) availSize );
192
193 // -- Compress event
194 mySize = fDataCompressor->CompressEvent( (UChar_t*) iter->fPtr );
195
196 // -- Fill output blocks
197 AliHLTComponentBlockData bd;
198 FillBlockData( bd );
199 bd.fOffset = offset;
200 bd.fSize = mySize;
201 bd.fSpecification = iter->fSpecification;
202 bd.fDataType = iter->fDataType;
203 outputBlocks.push_back( bd );
204
205 // -- Increase size counters
206 totalSize += mySize;
207
208 // -- Increase output shm ptr
209 outShmPtr += mySize;
859fbc05 210
0c7d42ab 211 // -- Check if data was written over allowed buffer
212 if ( totalSize > size ) {
859fbc05 213 HLTError( "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", totalSize, size );
0c7d42ab 214 return EMSGSIZE;
215 }
216
217 } // for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
218
219 // -- Set total output size
220 size = totalSize;
221
222 return 0;
223}