]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
Added a dummy component into the sample library.
[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> *
8 * for The ALICE Off-line 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///////////////////////////////////////////////////////////////////////////////
20// //
21// a TPC cluster finder processing component for the HLT //
22// //
23///////////////////////////////////////////////////////////////////////////////
24
25#if __GNUC__== 3
26using namespace std;
27#endif
28
29#include "AliHLTTPCClusterFinderComponent.h"
30#include "AliL3ClustFinderNew.h"
31#include "AliL3SpacePointData.h"
32#include "AliHLTTPCRawDataFormat.h"
33#include "AliHLTTPCClusterDataFormat.h"
34#include "AliL3Transform.h"
35#include <stdlib.h>
36#include <errno.h>
37
38// this is a global object used for automatic component registration, do not use this
39AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponent;
40
41ClassImp(AliHLTTPCClusterFinderComponent)
42
43AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent()
44 {
45 fClusterFinder = NULL;
46 fClusterDeconv = true;
47 fXYClusterError = -1;
48 fZClusterError = -1;
49 }
50
51AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
52 {
53 }
54
55// Public functions to implement AliHLTComponent's interface.
56// These functions are required for the registration process
57
58const char* AliHLTTPCClusterFinderComponent::GetComponentID()
59 {
60 return "TPCClusterFinder";
61 }
62
63void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
64 {
65 list.clear();
66 list.push_back( AliHLTTPCDefinitions::gkUnpackedRawDataType );
67 }
68
69AliHLTComponent_DataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
70 {
71 return AliHLTTPCDefinitions::gkClustersDataType;
72 }
73
74void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
75 {
76 // XXX TODO: Find more realistic values.
77 constBase = 0;
78 inputMultiplier = 0.4;
79 }
80
81AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
82 {
83 return new AliHLTTPCClusterFinderComponent;
84 }
85
86int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
87 {
88 if ( fClusterFinder )
89 return EINPROGRESS;
90 fClusterFinder = new AliL3ClustFinderNew();
91 fClusterDeconv = true;
92 fXYClusterError = -1;
93 fZClusterError = -1;
94 int i = 0;
95 while ( i < argc )
96 {
97 if ( !strcmp( argv[i], "-pp-run" ) )
98 {
99 fClusterDeconv = false;
100 i++;
101 continue;
102 }
103 Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
104 return EINVAL;
105 }
106 return 0;
107 }
108
109int AliHLTTPCClusterFinderComponent::DoDeinit()
110 {
111 if ( !fClusterFinder )
112 return ECANCELED;
113 if ( fClusterFinder )
114 delete fClusterFinder;
115 fClusterFinder = NULL;
116 return 0;
117 }
118
119int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks,
120 AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr,
121 AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
122 {
123 const AliHLTComponent_BlockData* iter = NULL;
124 unsigned long ndx;
125 AliHLTTPCUnpackedRawData* inPtr;
126 AliHLTTPCClusterData* outPtr;
127 AliHLTUInt8_t* outBPtr;
128 UInt_t offset, mysize, nSize, tSize = 0;
129 outBPtr = outputPtr;
130 outPtr = (AliHLTTPCClusterData*)outBPtr;
131 Int_t slice, patch, row[2];
132 unsigned long maxPoints, realPoints = 0;
133 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
134 {
135 iter = blocks+ndx;
136 mysize = 0;
137 offset = tSize;
138 if ( iter->fDataType != AliHLTTPCDefinitions::gkUnpackedRawDataType )
139 continue;
140
141 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
142 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
143 row[0] = AliL3Transform::GetFirstRow( patch );
144 row[1] = AliL3Transform::GetLastRow( patch );
145
146 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints",
147 "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
148 realPoints, slice, patch, row[0], row[1] );
149
150 outPtr = (AliHLTTPCClusterData*)outBPtr;
151
152 inPtr = (AliHLTTPCUnpackedRawData*)iter->fPtr;
153 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliL3SpacePointData);
154
155 fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
156 fClusterFinder->SetDeconv( fClusterDeconv );
157 fClusterFinder->SetXYError( fXYClusterError );
158 fClusterFinder->SetZError( fZClusterError );
159 if ( (fXYClusterError>0) && (fZClusterError>0) )
160 fClusterFinder->SetCalcErr( false );
161 fClusterFinder->SetOutputArray( outPtr->fSpacePoints );
162 fClusterFinder->Read( maxPoints, inPtr->fDigits );
163 fClusterFinder->ProcessDigits();
164 realPoints = fClusterFinder->GetNumberOfClusters();
165
166 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints",
167 "Number of spacepoints found: %lu.", realPoints );
168
169 outPtr->fSpacePointCnt = realPoints;
170 nSize = sizeof(AliL3SpacePointData)*realPoints;
171 mysize += nSize+sizeof(AliHLTTPCClusterData);
172
173 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints",
174 "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
175 realPoints, slice, patch, row[0], row[1] );
176
177
178 AliHLTComponent_BlockData bd;
179 FillBlockData( bd );
180 bd.fOffset = offset;
181 bd.fSize = mysize;
182 bd.fSpecification = iter->fSpecification;
183 //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
184 outputBlocks.push_back( bd );
185
186 tSize += mysize;
187 outBPtr += mysize;
188 outPtr = (AliHLTTPCClusterData*)outBPtr;
189
190 if ( tSize > size )
191 {
192 Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
193 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
194 tSize, size );
195 return EMSGSIZE;
196 }
197 }
198
199 size = tSize;
200 return 0;
201 }
202
203