]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCVertexFinderComponent.cxx
f6a96fdcf03f9d0aefd83a21b8ff0070bf979827
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCVertexFinderComponent.cxx
1 // $Id$
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: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
9  *                  for The ALICE HLT 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 vertex finder processing component for the HLT                     //
23 //                                                                           //
24 ///////////////////////////////////////////////////////////////////////////////
25
26 #if __GNUC__== 3
27 using namespace std;
28 #endif
29
30 #include "AliHLTTPCVertexFinderComponent.h"
31 #include "AliHLTTPCVertexFinder.h"
32 #include "AliHLTTPCSpacePointData.h"
33 #include "AliHLTTPCVertexData.h"
34 #include "AliHLTTPCClusterDataFormat.h"
35 #include "AliHLTTPCTransform.h"
36 #include <stdlib.h>
37 #include <errno.h>
38
39 // this is a global object used for automatic component registration, do not use this
40 AliHLTTPCVertexFinderComponent gAliHLTTPCVertexFinderComponent;
41
42 ClassImp(AliHLTTPCVertexFinderComponent)
43
44 AliHLTTPCVertexFinderComponent::AliHLTTPCVertexFinderComponent()
45     {
46     fVertexFinder = NULL;
47     }
48
49 AliHLTTPCVertexFinderComponent::~AliHLTTPCVertexFinderComponent()
50     {
51     }
52
53 // Public functions to implement AliHLTComponent's interface.
54 // These functions are required for the registration process
55
56 const char* AliHLTTPCVertexFinderComponent::GetComponentID()
57     {
58     return "TPCVertexFinder";
59     }
60
61 void AliHLTTPCVertexFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
62     {
63     list.clear();
64     list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
65     }
66
67 AliHLTComponentDataType AliHLTTPCVertexFinderComponent::GetOutputDataType()
68     {
69     return AliHLTTPCDefinitions::fgkVertexDataType;
70     }
71
72 void AliHLTTPCVertexFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
73     {
74     // XXX TODO: Find more realistic values.
75     constBase = sizeof(AliHLTTPCVertexData);
76     inputMultiplier = 0;
77     }
78
79 AliHLTComponent* AliHLTTPCVertexFinderComponent::Spawn()
80     {
81     return new AliHLTTPCVertexFinderComponent;
82     }
83         
84 int AliHLTTPCVertexFinderComponent::DoInit( int argc, const char** argv )
85     {
86     if ( fVertexFinder )
87         return EINPROGRESS;
88     fVertexFinder = new AliHLTTPCVertexFinder();
89     return 0;
90     }
91
92 int AliHLTTPCVertexFinderComponent::DoDeinit()
93     {
94     if ( !fVertexFinder )
95         return ECANCELED;
96     if ( fVertexFinder )
97         delete fVertexFinder;
98     fVertexFinder = NULL;
99     return 0;
100     }
101
102 int AliHLTTPCVertexFinderComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
103                                               AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
104                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
105     {
106     const AliHLTComponentBlockData* iter = NULL;
107     unsigned long ndx;
108
109     AliHLTTPCClusterData* inPtr;
110     AliHLTTPCVertexData* outPtr;
111     AliHLTUInt8_t* outBPtr;
112     UInt_t offset, mysize, tSize = 0;
113     outBPtr = outputPtr;
114     Int_t slice, patch, row[2];
115     AliHLTUInt32_t realPoints;
116
117     for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
118         {
119         iter = blocks+ndx;
120         mysize = 0;
121         offset = tSize;
122         if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType )
123             {
124             continue;
125             }
126         
127         inPtr = (AliHLTTPCClusterData*)(iter->fPtr);
128         slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
129         patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
130         row[0] = AliHLTTPCTransform::GetFirstRow( patch );
131         row[1] = AliHLTTPCTransform::GetLastRow( patch );
132         realPoints = inPtr->fSpacePointCnt;
133
134         Logging( kHLTLogDebug, "HLT::TPCVertexFinder::DoEvent", "Spacepoint count",
135                  "realpoints: %lu.", realPoints );
136         
137         outPtr = (AliHLTTPCVertexData*)outBPtr;
138
139         fVertexFinder->Reset();
140         
141         fVertexFinder->Read( realPoints, inPtr->fSpacePoints );
142         fVertexFinder->Analyze();
143
144         //publish Vertex
145         fVertexFinder->Write( outPtr );
146
147
148         mysize += sizeof(AliHLTTPCVertexData);
149         
150         AliHLTComponentBlockData bd;
151         FillBlockData( bd );
152         bd.fOffset = offset;
153         bd.fSize = mysize;
154         bd.fSpecification = iter->fSpecification;
155         //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
156         outputBlocks.push_back( bd );
157
158         tSize += mysize;
159         outBPtr += mysize;
160
161         if ( tSize > size )
162             {
163             Logging( kHLTLogFatal, "HLT::TPCVertexFinder::DoEvent", "Too much data",
164                      "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
165                      , tSize, size );
166             return EMSGSIZE;
167             }
168         }
169     
170     size = tSize;
171     return 0;
172     }
173
174