]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCVertexFinderComponent.cxx
bugfix: corrected defines to use right default algorithms
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCVertexFinderComponent.cxx
CommitLineData
71d7c760 1// $Id$
2
3/**************************************************************************
9be2600f 4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
71d7c760 6 * *
9be2600f 7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 * for The ALICE HLT Project. *
71d7c760 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
e67b0680 20/** @file AliHLTTPCVertexFinderComponent.cxx
21 @author Timm Steinbeck, Matthias Richter
22 @date
23 @brief TPC vertex finder processing component
24*/
25
71d7c760 26///////////////////////////////////////////////////////////////////////////////
27// //
e67b0680 28// a TPC vertex finder processing component for the HLT //
29// //
30// see header file for class documentation //
31// or //
32// refer to README to build package //
33// or //
34// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
71d7c760 35// //
36///////////////////////////////////////////////////////////////////////////////
37
e67b0680 38#if __GNUC__>= 3
71d7c760 39using namespace std;
40#endif
41
42#include "AliHLTTPCVertexFinderComponent.h"
a6c02c85 43#include "AliHLTTPCVertexFinder.h"
44#include "AliHLTTPCSpacePointData.h"
45#include "AliHLTTPCVertexData.h"
71d7c760 46#include "AliHLTTPCClusterDataFormat.h"
a6c02c85 47#include "AliHLTTPCTransform.h"
e67b0680 48#include "AliHLTTPCDefinitions.h"
49#include <cstdlib>
50#include <cerrno>
71d7c760 51
52// this is a global object used for automatic component registration, do not use this
53AliHLTTPCVertexFinderComponent gAliHLTTPCVertexFinderComponent;
54
e67b0680 55ClassImp(AliHLTTPCVertexFinderComponent);
71d7c760 56
57AliHLTTPCVertexFinderComponent::AliHLTTPCVertexFinderComponent()
e419b223 58 :
5d2abf3b 59 AliHLTProcessor(),
e419b223 60 fVertexFinder(NULL)
61{
e67b0680 62 // see header file for class documentation
63 // or
64 // refer to README to build package
65 // or
66 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
e419b223 67}
68
69AliHLTTPCVertexFinderComponent::AliHLTTPCVertexFinderComponent(const AliHLTTPCVertexFinderComponent&)
70 :
5d2abf3b 71 AliHLTProcessor(),
e419b223 72 fVertexFinder(NULL)
73{
74 // see header file for class documentation
75}
76
77AliHLTTPCVertexFinderComponent& AliHLTTPCVertexFinderComponent::operator=(const AliHLTTPCVertexFinderComponent&)
78{
79 // see header file for class documentation
80 return *this;
81}
71d7c760 82
83AliHLTTPCVertexFinderComponent::~AliHLTTPCVertexFinderComponent()
e419b223 84{
e67b0680 85 // see header file for class documentation
e419b223 86}
71d7c760 87
88// Public functions to implement AliHLTComponent's interface.
89// These functions are required for the registration process
90
91const char* AliHLTTPCVertexFinderComponent::GetComponentID()
e67b0680 92{
93 // see header file for class documentation
94 return "TPCVertexFinder";
95}
71d7c760 96
8ede8717 97void AliHLTTPCVertexFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
e67b0680 98{
99 // see header file for class documentation
100 list.clear();
101 list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
102}
71d7c760 103
8ede8717 104AliHLTComponentDataType AliHLTTPCVertexFinderComponent::GetOutputDataType()
e67b0680 105{
106 // see header file for class documentation
107 return AliHLTTPCDefinitions::fgkVertexDataType;
108}
71d7c760 109
110void AliHLTTPCVertexFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
e67b0680 111{
112 // see header file for class documentation
113 // XXX TODO: Find more realistic values.
114 constBase = sizeof(AliHLTTPCVertexData);
115 inputMultiplier = 0;
116}
71d7c760 117
118AliHLTComponent* AliHLTTPCVertexFinderComponent::Spawn()
e67b0680 119{
120 // see header file for class documentation
121 return new AliHLTTPCVertexFinderComponent;
122}
123
5d2abf3b 124int AliHLTTPCVertexFinderComponent::DoInit( int /*argc*/, const char** /*argv*/ )
e67b0680 125{
126 // see header file for class documentation
127 if ( fVertexFinder )
128 return EINPROGRESS;
129 fVertexFinder = new AliHLTTPCVertexFinder();
130 return 0;
131}
71d7c760 132
133int AliHLTTPCVertexFinderComponent::DoDeinit()
e67b0680 134{
135 // see header file for class documentation
136 if ( !fVertexFinder )
137 return ECANCELED;
138 if ( fVertexFinder )
139 delete fVertexFinder;
140 fVertexFinder = NULL;
141 return 0;
142}
71d7c760 143
8ede8717 144int AliHLTTPCVertexFinderComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
5d2abf3b 145 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
8ede8717 146 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
e67b0680 147{
148 // see header file for class documentation
149 const AliHLTComponentBlockData* iter = NULL;
150 unsigned long ndx;
151
152 AliHLTTPCClusterData* inPtr;
153 AliHLTTPCVertexData* outPtr;
154 AliHLTUInt8_t* outBPtr;
155 UInt_t offset, mysize, tSize = 0;
156 outBPtr = outputPtr;
157 Int_t slice, patch, row[2];
158 AliHLTUInt32_t realPoints;
159
160 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
71d7c760 161 {
e67b0680 162 iter = blocks+ndx;
163 mysize = 0;
164 offset = tSize;
165 if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType )
71d7c760 166 {
e67b0680 167 continue;
168 }
71d7c760 169
e67b0680 170 inPtr = (AliHLTTPCClusterData*)(iter->fPtr);
171 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
172 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
173 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
174 row[1] = AliHLTTPCTransform::GetLastRow( patch );
175 realPoints = inPtr->fSpacePointCnt;
176
177 Logging( kHLTLogDebug, "HLT::TPCVertexFinder::DoEvent", "Spacepoint count",
178 "realpoints: %lu.", realPoints );
71d7c760 179
e67b0680 180 outPtr = (AliHLTTPCVertexData*)outBPtr;
71d7c760 181
e67b0680 182 fVertexFinder->Reset();
71d7c760 183
e67b0680 184 fVertexFinder->Read( realPoints, inPtr->fSpacePoints );
185 fVertexFinder->Analyze();
71d7c760 186
e67b0680 187 //publish Vertex
188 fVertexFinder->Write( outPtr );
71d7c760 189
190
e67b0680 191 mysize += sizeof(AliHLTTPCVertexData);
71d7c760 192
e67b0680 193 AliHLTComponentBlockData bd;
194 FillBlockData( bd );
195 bd.fOffset = offset;
196 bd.fSize = mysize;
197 bd.fSpecification = iter->fSpecification;
198 //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
199 outputBlocks.push_back( bd );
200
201 tSize += mysize;
202 outBPtr += mysize;
203
204 if ( tSize > size )
205 {
206 Logging( kHLTLogFatal, "HLT::TPCVertexFinder::DoEvent", "Too much data",
207 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
208 , tSize, size );
209 return EMSGSIZE;
71d7c760 210 }
71d7c760 211 }
e67b0680 212
213 size = tSize;
214 return 0;
215}
71d7c760 216
217