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: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTITSCompressRawDataSDDComponent.cxx
20 @author Jochen Thaeder <thaeder@kip.uni-heidelberg.de>
22 @brief Component to run data compression for SDD
30 #include "AliHLTITSCompressRawDataSDDComponent.h"
32 #include "AliCDBEntry.h"
33 #include "AliCDBManager.h"
38 #include "TObjString.h"
41 /** ROOT macro for the implementation of ROOT specific class methods */
42 ClassImp(AliHLTITSCompressRawDataSDDComponent);
44 AliHLTITSCompressRawDataSDDComponent::AliHLTITSCompressRawDataSDDComponent()
46 fDataCompressor(NULL),
48 // see header file for class documentation
50 // refer to README to build package
52 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
55 AliHLTITSCompressRawDataSDDComponent::~AliHLTITSCompressRawDataSDDComponent() {
56 // see header file for class documentation
59 // Public functions to implement AliHLTComponent's interface.
60 // These functions are required for the registration process
62 const char* AliHLTITSCompressRawDataSDDComponent::GetComponentID()
64 // see header file for class documentation
66 return "ITSDataCompressorSDD";
69 void AliHLTITSCompressRawDataSDDComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
70 // see header file for class documentation
72 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITS );
76 AliHLTComponentDataType AliHLTITSCompressRawDataSDDComponent::GetOutputDataType() {
77 // see header file for class documentation
78 return (kAliHLTDataTypeDDLRaw| kAliHLTDataOriginITS);
81 void AliHLTITSCompressRawDataSDDComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
82 // see header file for class documentation
85 inputMultiplier = 0.3;
88 AliHLTComponent* AliHLTITSCompressRawDataSDDComponent::Spawn() {
89 // see header file for class documentation
90 return new AliHLTITSCompressRawDataSDDComponent();
93 Int_t AliHLTITSCompressRawDataSDDComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
94 // see header file for class documentation
96 if ( fDataCompressor )
99 fDataCompressor = new AliITSCompressRawDataSDD();
104 fRawReader = new AliRawReaderMemory();
109 Int_t AliHLTITSCompressRawDataSDDComponent::DoDeinit() {
110 // see header file for class documentation
116 if ( fDataCompressor )
117 delete fDataCompressor;
118 fDataCompressor = NULL;
123 Int_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
130 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
135 // -- Iterator over Data Blocks --
136 const AliHLTComponentBlockData* iter = NULL;
138 // -- Ptr to output shm region --
139 AliHLTUInt8_t* outShmPtr = outputPtr;
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
147 // -- Loop over blocks
148 for ( ULong_t ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
154 availSize = size - totalSize;
156 // -- Debug output of datatype --
157 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
158 evtData.fEventID, evtData.fEventID,
159 DataType2Text(iter->fDataType).c_str(),
160 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD).c_str());
162 // -- Check for the correct data type
163 if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD) )
167 fRawReader->SetMemory( (UChar_t*) iter->fPtr, iter->fSize );
169 // -- Get equipment ID out of specification
170 AliHLTUInt32_t spec = iter->fSpecification;
173 for ( Int_t ii = 0; ii < 24 ; ii++ ) {
174 if ( spec & 0x00000001 ) {
181 // -- Set equipment ID to the raw reader
182 fRawReader->SetEquipmentID( id );
185 fDataCompressor->SetRawReader( fRawReader );
187 // -- Set ptr to output shm
188 fDataCompressor->SetPointerToData( (UChar_t*) outShmPtr );
190 // -- Set availible outputspace
191 fDataCompressor->SetSize( (UInt_t) availSize );
194 mySize = fDataCompressor->CompressEvent( (UChar_t*) iter->fPtr );
196 // -- Fill output blocks
197 AliHLTComponentBlockData bd;
201 bd.fSpecification = iter->fSpecification;
202 bd.fDataType = iter->fDataType;
203 outputBlocks.push_back( bd );
205 // -- Increase size counters
208 // -- Increase output shm ptr
211 // -- Check if data was written over allowed buffer
212 if ( totalSize > size ) {
213 HLTError( "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", totalSize, size );
217 } // for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
219 // -- Set total output size