]>
Commit | Line | Data |
---|---|---|
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 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTTPCClusterFinderComponent.h" | |
a6c02c85 | 30 | #include "AliHLTTPCClustFinderNew.h" |
31 | #include "AliHLTTPCSpacePointData.h" | |
71d7c760 | 32 | #include "AliHLTTPCRawDataFormat.h" |
33 | #include "AliHLTTPCClusterDataFormat.h" | |
a6c02c85 | 34 | #include "AliHLTTPCTransform.h" |
71d7c760 | 35 | #include <stdlib.h> |
36 | #include <errno.h> | |
37 | ||
38 | // this is a global object used for automatic component registration, do not use this | |
39 | AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponent; | |
40 | ||
41 | ClassImp(AliHLTTPCClusterFinderComponent) | |
42 | ||
43 | AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent() | |
44 | { | |
45 | fClusterFinder = NULL; | |
46 | fClusterDeconv = true; | |
47 | fXYClusterError = -1; | |
48 | fZClusterError = -1; | |
49 | } | |
50 | ||
51 | AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent() | |
52 | { | |
53 | } | |
54 | ||
55 | // Public functions to implement AliHLTComponent's interface. | |
56 | // These functions are required for the registration process | |
57 | ||
58 | const char* AliHLTTPCClusterFinderComponent::GetComponentID() | |
59 | { | |
60 | return "TPCClusterFinder"; | |
61 | } | |
62 | ||
63 | void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
64 | { | |
65 | list.clear(); | |
66 | list.push_back( AliHLTTPCDefinitions::gkUnpackedRawDataType ); | |
67 | } | |
68 | ||
69 | AliHLTComponent_DataType AliHLTTPCClusterFinderComponent::GetOutputDataType() | |
70 | { | |
71 | return AliHLTTPCDefinitions::gkClustersDataType; | |
72 | } | |
73 | ||
74 | void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
75 | { | |
76 | // XXX TODO: Find more realistic values. | |
77 | constBase = 0; | |
78 | inputMultiplier = 0.4; | |
79 | } | |
80 | ||
81 | AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn() | |
82 | { | |
83 | return new AliHLTTPCClusterFinderComponent; | |
84 | } | |
85 | ||
86 | int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv ) | |
87 | { | |
88 | if ( fClusterFinder ) | |
89 | return EINPROGRESS; | |
a6c02c85 | 90 | fClusterFinder = new AliHLTTPCClustFinderNew(); |
71d7c760 | 91 | fClusterDeconv = true; |
92 | fXYClusterError = -1; | |
93 | fZClusterError = -1; | |
94 | int i = 0; | |
95 | while ( i < argc ) | |
96 | { | |
a6c02c85 | 97 | if ( !strcmp( argv[i], "pp-run" ) ) |
71d7c760 | 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 | ||
109 | int AliHLTTPCClusterFinderComponent::DoDeinit() | |
110 | { | |
111 | if ( !fClusterFinder ) | |
112 | return ECANCELED; | |
113 | if ( fClusterFinder ) | |
114 | delete fClusterFinder; | |
115 | fClusterFinder = NULL; | |
116 | return 0; | |
117 | } | |
118 | ||
119 | int 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; | |
a6c02c85 | 138 | char tmp1[14], tmp2[14]; |
139 | DataType2Text( iter->fDataType, tmp1 ); | |
140 | DataType2Text( AliHLTTPCDefinitions::gkUnpackedRawDataType, tmp2 ); | |
141 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received", | |
142 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
143 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
71d7c760 | 144 | if ( iter->fDataType != AliHLTTPCDefinitions::gkUnpackedRawDataType ) |
145 | continue; | |
146 | ||
147 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); | |
148 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
a6c02c85 | 149 | row[0] = AliHLTTPCTransform::GetFirstRow( patch ); |
150 | row[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
71d7c760 | 151 | |
152 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", | |
153 | "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
154 | realPoints, slice, patch, row[0], row[1] ); | |
155 | ||
156 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
157 | ||
158 | inPtr = (AliHLTTPCUnpackedRawData*)iter->fPtr; | |
a6c02c85 | 159 | maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData); |
71d7c760 | 160 | |
161 | fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints ); | |
162 | fClusterFinder->SetDeconv( fClusterDeconv ); | |
163 | fClusterFinder->SetXYError( fXYClusterError ); | |
164 | fClusterFinder->SetZError( fZClusterError ); | |
165 | if ( (fXYClusterError>0) && (fZClusterError>0) ) | |
166 | fClusterFinder->SetCalcErr( false ); | |
167 | fClusterFinder->SetOutputArray( outPtr->fSpacePoints ); | |
168 | fClusterFinder->Read( maxPoints, inPtr->fDigits ); | |
169 | fClusterFinder->ProcessDigits(); | |
170 | realPoints = fClusterFinder->GetNumberOfClusters(); | |
171 | ||
172 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints", | |
173 | "Number of spacepoints found: %lu.", realPoints ); | |
174 | ||
175 | outPtr->fSpacePointCnt = realPoints; | |
a6c02c85 | 176 | nSize = sizeof(AliHLTTPCSpacePointData)*realPoints; |
71d7c760 | 177 | mysize += nSize+sizeof(AliHLTTPCClusterData); |
178 | ||
179 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", | |
180 | "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
181 | realPoints, slice, patch, row[0], row[1] ); | |
182 | ||
183 | ||
184 | AliHLTComponent_BlockData bd; | |
185 | FillBlockData( bd ); | |
186 | bd.fOffset = offset; | |
187 | bd.fSize = mysize; | |
188 | bd.fSpecification = iter->fSpecification; | |
189 | //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes ); | |
190 | outputBlocks.push_back( bd ); | |
191 | ||
192 | tSize += mysize; | |
193 | outBPtr += mysize; | |
194 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
195 | ||
196 | if ( tSize > size ) | |
197 | { | |
198 | Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data", | |
199 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", | |
200 | tSize, size ); | |
201 | return EMSGSIZE; | |
202 | } | |
203 | } | |
204 | ||
205 | size = tSize; | |
206 | return 0; | |
207 | } | |
208 | ||
209 |