3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
8 * for The ALICE Off-line Project. *
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 **************************************************************************/
19 ///////////////////////////////////////////////////////////////////////////////
21 // a TPC cluster finder processing component for the HLT //
23 ///////////////////////////////////////////////////////////////////////////////
29 #include "AliHLTTPCClusterFinderComponent.h"
30 #include "AliL3ClustFinderNew.h"
31 #include "AliL3SpacePointData.h"
32 #include "AliHLTTPCRawDataFormat.h"
33 #include "AliHLTTPCClusterDataFormat.h"
34 #include "AliL3Transform.h"
38 // this is a global object used for automatic component registration, do not use this
39 AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponent;
41 ClassImp(AliHLTTPCClusterFinderComponent)
43 AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent()
45 fClusterFinder = NULL;
46 fClusterDeconv = true;
51 AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
55 // Public functions to implement AliHLTComponent's interface.
56 // These functions are required for the registration process
58 const char* AliHLTTPCClusterFinderComponent::GetComponentID()
60 return "TPCClusterFinder";
63 void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
66 list.push_back( AliHLTTPCDefinitions::gkUnpackedRawDataType );
69 AliHLTComponent_DataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
71 return AliHLTTPCDefinitions::gkClustersDataType;
74 void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
76 // XXX TODO: Find more realistic values.
78 inputMultiplier = 0.4;
81 AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
83 return new AliHLTTPCClusterFinderComponent;
86 int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
90 fClusterFinder = new AliL3ClustFinderNew();
91 fClusterDeconv = true;
97 if ( !strcmp( argv[i], "-pp-run" ) )
99 fClusterDeconv = false;
103 Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
109 int AliHLTTPCClusterFinderComponent::DoDeinit()
111 if ( !fClusterFinder )
113 if ( fClusterFinder )
114 delete fClusterFinder;
115 fClusterFinder = NULL;
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 )
123 const AliHLTComponent_BlockData* iter = NULL;
125 AliHLTTPCUnpackedRawData* inPtr;
126 AliHLTTPCClusterData* outPtr;
127 AliHLTUInt8_t* outBPtr;
128 UInt_t offset, mysize, nSize, tSize = 0;
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++ )
138 if ( iter->fDataType != AliHLTTPCDefinitions::gkUnpackedRawDataType )
141 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
142 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
143 row[0] = AliL3Transform::GetFirstRow( patch );
144 row[1] = AliL3Transform::GetLastRow( patch );
146 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints",
147 "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
148 realPoints, slice, patch, row[0], row[1] );
150 outPtr = (AliHLTTPCClusterData*)outBPtr;
152 inPtr = (AliHLTTPCUnpackedRawData*)iter->fPtr;
153 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliL3SpacePointData);
155 fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
156 fClusterFinder->SetDeconv( fClusterDeconv );
157 fClusterFinder->SetXYError( fXYClusterError );
158 fClusterFinder->SetZError( fZClusterError );
159 if ( (fXYClusterError>0) && (fZClusterError>0) )
160 fClusterFinder->SetCalcErr( false );
161 fClusterFinder->SetOutputArray( outPtr->fSpacePoints );
162 fClusterFinder->Read( maxPoints, inPtr->fDigits );
163 fClusterFinder->ProcessDigits();
164 realPoints = fClusterFinder->GetNumberOfClusters();
166 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints",
167 "Number of spacepoints found: %lu.", realPoints );
169 outPtr->fSpacePointCnt = realPoints;
170 nSize = sizeof(AliL3SpacePointData)*realPoints;
171 mysize += nSize+sizeof(AliHLTTPCClusterData);
173 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints",
174 "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
175 realPoints, slice, patch, row[0], row[1] );
178 AliHLTComponent_BlockData bd;
182 bd.fSpecification = iter->fSpecification;
183 //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
184 outputBlocks.push_back( bd );
188 outPtr = (AliHLTTPCClusterData*)outBPtr;
192 Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
193 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",