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