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