]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
Adding the AliRunTagCuts class in the repository.
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterFinderComponent.cxx
CommitLineData
71d7c760 1// $Id$
2
3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
a38a7850 8 * Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
71d7c760 9 * for The ALICE Off-line Project. *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19
20///////////////////////////////////////////////////////////////////////////////
21// //
22// a TPC cluster finder processing component for the HLT //
a38a7850 23// useable for packed data or unpacked data //
71d7c760 24// //
25///////////////////////////////////////////////////////////////////////////////
26
a38a7850 27
71d7c760 28#if __GNUC__== 3
29using namespace std;
30#endif
31
32#include "AliHLTTPCClusterFinderComponent.h"
a38a7850 33#include "AliHLTTPCDigitReaderPacked.h"
34#include "AliHLTTPCDigitReaderUnpacked.h"
35#include "AliHLTTPCClusterFinder.h"
a6c02c85 36#include "AliHLTTPCSpacePointData.h"
71d7c760 37#include "AliHLTTPCRawDataFormat.h"
38#include "AliHLTTPCClusterDataFormat.h"
a6c02c85 39#include "AliHLTTPCTransform.h"
71d7c760 40#include <stdlib.h>
41#include <errno.h>
42
43// this is a global object used for automatic component registration, do not use this
a38a7850 44AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentPacked(true);
45AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentUnpacked(false);
71d7c760 46
47ClassImp(AliHLTTPCClusterFinderComponent)
48
a38a7850 49AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(bool packed)
74c73e5a 50 :
51 // use fPackedSwitch = true for packed inputtype "gkDDLPackedRawDataType"
52 // use fPackedSwitch = false for unpacked inputtype "gkUnpackedRawDataType"
53 fPackedSwitch(packed),
54
55 fClusterFinder(NULL),
56 fReader(NULL),
57 fClusterDeconv(true),
58 fXYClusterError(-1),
59 fZClusterError(-1)
60{
61}
62
63AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(const AliHLTTPCClusterFinderComponent&)
64 :
65 fPackedSwitch(0),
66 fClusterFinder(NULL),
67 fReader(NULL),
68 fClusterDeconv(true),
69 fXYClusterError(-1),
70 fZClusterError(-1)
71{
72 HLTFatal("copy constructor untested");
73}
74
75AliHLTTPCClusterFinderComponent& AliHLTTPCClusterFinderComponent::operator=(const AliHLTTPCClusterFinderComponent&)
76{
77 HLTFatal("assignment operator untested");
78 return *this;
79}
71d7c760 80
81AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
82 {
83 }
84
85// Public functions to implement AliHLTComponent's interface.
86// These functions are required for the registration process
87
88const char* AliHLTTPCClusterFinderComponent::GetComponentID()
89 {
a38a7850 90 if (fPackedSwitch) return "TPCClusterFinderPacked";
91 else return "TPCClusterFinderUnpacked";
71d7c760 92 }
93
94void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
95 {
a38a7850 96 list.clear();
97 if (fPackedSwitch) list.push_back( AliHLTTPCDefinitions::gkDDLPackedRawDataType );
98 else list.push_back( AliHLTTPCDefinitions::gkUnpackedRawDataType );
99
71d7c760 100 }
101
102AliHLTComponent_DataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
103 {
104 return AliHLTTPCDefinitions::gkClustersDataType;
105 }
106
107void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
108 {
a38a7850 109 // XXX TODO: Find more realistic values.
71d7c760 110 constBase = 0;
a38a7850 111 if (fPackedSwitch) inputMultiplier = (6 * 0.4);
112 else inputMultiplier = 0.4;
71d7c760 113 }
114
115AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
116 {
a38a7850 117 return new AliHLTTPCClusterFinderComponent(fPackedSwitch);
71d7c760 118 }
119
120int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
121 {
122 if ( fClusterFinder )
123 return EINPROGRESS;
a38a7850 124
125 fClusterFinder = new AliHLTTPCClusterFinder();
126
127 if (fPackedSwitch) {
74c73e5a 128#if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
129 fReader = new AliHLTTPCDigitReaderPacked();
130 fClusterFinder->SetReader(fReader);
131#else // ! defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
132 HLTFatal("DigitReaderPacked not available - check your build");
133 return -ENODEV;
134#endif // defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
a38a7850 135 }
136 else {
74c73e5a 137 fReader = new AliHLTTPCDigitReaderUnpacked();
138 fClusterFinder->SetReader(fReader);
a38a7850 139 }
140
141 // Variables to setup the Clusterfinder
71d7c760 142 fClusterDeconv = true;
143 fXYClusterError = -1;
144 fZClusterError = -1;
a38a7850 145
71d7c760 146 int i = 0;
147 while ( i < argc )
148 {
a38a7850 149 if ( !strcmp( argv[i], "pp-run" ) ){
71d7c760 150 fClusterDeconv = false;
151 i++;
152 continue;
a38a7850 153 }
154
71d7c760 155 Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
156 return EINVAL;
157 }
a38a7850 158
159
160 fClusterFinder->SetDeconv( fClusterDeconv );
161 fClusterFinder->SetXYError( fXYClusterError );
162 fClusterFinder->SetZError( fZClusterError );
163 if ( (fXYClusterError>0) && (fZClusterError>0) )
164 fClusterFinder->SetCalcErr( false );
165
71d7c760 166 return 0;
167 }
168
169int AliHLTTPCClusterFinderComponent::DoDeinit()
170 {
a38a7850 171
71d7c760 172 if ( fClusterFinder )
173 delete fClusterFinder;
174 fClusterFinder = NULL;
a38a7850 175
74c73e5a 176 if ( fReader )
177 delete fReader;
178 fReader = NULL;
a38a7850 179
71d7c760 180 return 0;
181 }
182
a38a7850 183int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& evtData,
184 const AliHLTComponent_BlockData* blocks,
71d7c760 185 AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr,
a38a7850 186 AliHLTUInt32_t& size,
187 vector<AliHLTComponent_BlockData>& outputBlocks )
71d7c760 188 {
a38a7850 189 // == init iter (pointer to datablock)
71d7c760 190 const AliHLTComponent_BlockData* iter = NULL;
191 unsigned long ndx;
a38a7850 192
193 // == OUTdatatype pointer
71d7c760 194 AliHLTTPCClusterData* outPtr;
a38a7850 195
71d7c760 196 AliHLTUInt8_t* outBPtr;
197 UInt_t offset, mysize, nSize, tSize = 0;
a38a7850 198
71d7c760 199 outBPtr = outputPtr;
200 outPtr = (AliHLTTPCClusterData*)outBPtr;
a38a7850 201
71d7c760 202 Int_t slice, patch, row[2];
203 unsigned long maxPoints, realPoints = 0;
a38a7850 204
71d7c760 205 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
206 {
207 iter = blocks+ndx;
208 mysize = 0;
209 offset = tSize;
a38a7850 210
211
212 if (fPackedSwitch) {
213 char tmp1[14], tmp2[14];
214 DataType2Text( iter->fDataType, tmp1 );
215 DataType2Text( AliHLTTPCDefinitions::gkDDLPackedRawDataType, tmp2 );
216 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received",
217 "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
218 evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
219
220 if ( iter->fDataType != AliHLTTPCDefinitions::gkDDLPackedRawDataType ) continue;
221
222 }
223 else {
224 char tmp1[14], tmp2[14];
225 DataType2Text( iter->fDataType, tmp1 );
226 DataType2Text( AliHLTTPCDefinitions::gkUnpackedRawDataType, tmp2 );
227 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received",
228 "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
229 evtData.fEventID, evtData.fEventID, tmp1, tmp2 );
230
231 if ( iter->fDataType != AliHLTTPCDefinitions::gkUnpackedRawDataType ) continue;
232
233 }
234
71d7c760 235 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
236 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
a6c02c85 237 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
238 row[1] = AliHLTTPCTransform::GetLastRow( patch );
71d7c760 239
240 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints",
241 "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
242 realPoints, slice, patch, row[0], row[1] );
243
244 outPtr = (AliHLTTPCClusterData*)outBPtr;
a38a7850 245
a6c02c85 246 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
71d7c760 247
248 fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
71d7c760 249 fClusterFinder->SetOutputArray( outPtr->fSpacePoints );
a38a7850 250 fClusterFinder->Read(iter->fPtr, iter->fSize );
71d7c760 251 fClusterFinder->ProcessDigits();
252 realPoints = fClusterFinder->GetNumberOfClusters();
253
254 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints",
255 "Number of spacepoints found: %lu.", realPoints );
256
257 outPtr->fSpacePointCnt = realPoints;
a6c02c85 258 nSize = sizeof(AliHLTTPCSpacePointData)*realPoints;
71d7c760 259 mysize += nSize+sizeof(AliHLTTPCClusterData);
260
261 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints",
262 "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
263 realPoints, slice, patch, row[0], row[1] );
264
265
266 AliHLTComponent_BlockData bd;
267 FillBlockData( bd );
268 bd.fOffset = offset;
269 bd.fSize = mysize;
270 bd.fSpecification = iter->fSpecification;
271 //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
272 outputBlocks.push_back( bd );
273
274 tSize += mysize;
275 outBPtr += mysize;
276 outPtr = (AliHLTTPCClusterData*)outBPtr;
277
278 if ( tSize > size )
279 {
280 Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
281 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
282 tSize, size );
283 return EMSGSIZE;
284 }
285 }
286
287 size = tSize;
288 return 0;
289 }
290
a38a7850 291