3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Kenneth Aamodt *
9 * for The ALICE HLT Project. *
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 **************************************************************************/
20 /** @file AliHLTTPCKryptonClusterFinderComponent.cxx
21 @author Kenneth Aamodt, Kalliopi Kanaki
23 @brief The TPC krypton cluster finder processing component
26 // see header file for class documentation //
28 // refer to README to build package //
30 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
35 #include "AliHLTTPCKryptonClusterFinderComponent.h"
36 #include "AliHLTTPCDigitReaderDecoder.h"
37 #include "AliHLTTPCKryptonClusterFinder.h"
38 #include "AliHLTTPCSpacePointData.h"
39 #include "AliHLTTPCClusterDataFormat.h"
40 #include "AliHLTTPCTransform.h"
41 #include "AliHLTTPCClusters.h"
42 #include "AliHLTTPCDefinitions.h"
43 #include "AliCDBEntry.h"
44 #include "AliCDBManager.h"
50 #include "TObjString.h"
53 AliHLTTPCKryptonClusterFinderComponent gAliHLTTPCKryptonClusterFinderComponent;
55 /** ROOT macro for the implementation of ROOT specific class methods */
56 ClassImp(AliHLTTPCKryptonClusterFinderComponent)
58 AliHLTTPCKryptonClusterFinderComponent::AliHLTTPCKryptonClusterFinderComponent()
60 fKryptonClusterFinder(NULL),
64 // see header file for class documentation
66 // refer to README to build package
68 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
71 AliHLTTPCKryptonClusterFinderComponent::~AliHLTTPCKryptonClusterFinderComponent()
73 // see header file for class documentation
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
79 const char* AliHLTTPCKryptonClusterFinderComponent::GetComponentID()
81 // see header file for class documentation
82 return "TPCKryptonClusterFinder";
85 void AliHLTTPCKryptonClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
87 // see header file for class documentation
89 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
92 AliHLTComponentDataType AliHLTTPCKryptonClusterFinderComponent::GetOutputDataType()
94 // see header file for class documentation
95 return kAliHLTMultipleDataType;
96 // return kAliHLTDataTypeHistogram;
99 int AliHLTTPCKryptonClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
102 // see header file for class documentation
104 tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
105 tgtList.push_back(kAliHLTDataTypeHwAddr16);
106 return tgtList.size();
109 void AliHLTTPCKryptonClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
111 // see header file for class documentation
112 // XXX TODO: Find more realistic values.
114 inputMultiplier = (100 * 0.4);
117 AliHLTComponent* AliHLTTPCKryptonClusterFinderComponent::Spawn()
119 // see header file for class documentation
120 return new AliHLTTPCKryptonClusterFinderComponent();
123 int AliHLTTPCKryptonClusterFinderComponent::DoInit( int argc, const char** argv )
125 // see header file for class documentation
127 // HLTFatal("Initializing the kryptonclusterfindercomponent");
129 if ( fKryptonClusterFinder )
132 fKryptonClusterFinder = new AliHLTTPCKryptonClusterFinder();
138 //No arguments so far
140 Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
145 fReader = new AliHLTTPCDigitReaderDecoder();
146 fKryptonClusterFinder->SetReader(fReader);
151 int AliHLTTPCKryptonClusterFinderComponent::DoDeinit()
153 // see header file for class documentation
155 if ( fKryptonClusterFinder )
156 delete fKryptonClusterFinder;
157 fKryptonClusterFinder = NULL;
166 int AliHLTTPCKryptonClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData,
167 const AliHLTComponentBlockData* /*blocks*/,
168 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
169 AliHLTUInt32_t& size,
170 vector<AliHLTComponentBlockData>& outputBlocks )
172 // see header file for class documentation
174 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
179 // == init iter (pointer to datablock)
180 const AliHLTComponentBlockData* iter = NULL;
182 Int_t slice, patch, row[2];
184 unsigned long maxPoints = 0;
186 AliHLTTPCClusterData* outPtr;
188 outPtr = (AliHLTTPCClusterData*)outputPtr;
190 for (iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
192 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
193 evtData.fEventID, evtData.fEventID,
194 DataType2Text(iter->fDataType).c_str(),
195 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
197 if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){
198 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!",
199 DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
200 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
203 if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) &&
204 iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue;
206 fSpecification = iter->fSpecification;
208 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
209 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
210 row[0] = AliHLTTPCTransform::GetFirstRow( patch );
211 row[1] = AliHLTTPCTransform::GetLastRow( patch );
214 fKryptonClusterFinder->SetPatch(patch);
216 fKryptonClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
218 fKryptonClusterFinder->SetOutputArray((AliHLTTPCSpacePointData*)outPtr->fSpacePoints);
220 fKryptonClusterFinder->SetMaxOutputSize(size-sizeof(AliHLTUInt32_t));
222 fKryptonClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize);
224 fKryptonClusterFinder->FindRowClusters();
226 fKryptonClusterFinder->FindKryptonClusters();
228 // if(fKryptonClusterFinder->GetNKryptonClusters()>0){
230 // HLTFatal("Number of kryptonClusters: %d",(Int_t)fKryptonClusterFinder->GetNKryptonClusters());
232 if (sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData)>=size) {
233 HLTFatal("Buffer too small too add more spacepoints: %d of %d byte(s) already used",sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData) ,size);
237 outPtr->fSpacePointCnt=fKryptonClusterFinder->GetNKryptonClusters();
239 AliHLTComponentBlockData bd;
242 bd.fSize = sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData);
243 bd.fSpecification = iter->fSpecification;
244 bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
245 outputBlocks.push_back( bd );
247 //adding the list of hardware addresses to the outpot buffer
249 AliHLTUInt32_t dataOffsetBeforeHW=sizeof(AliHLTUInt32_t)+fKryptonClusterFinder->GetNKryptonClusters()*sizeof(AliHLTTPCSpacePointData);
250 AliHLTUInt32_t sizeOfHWArray=fKryptonClusterFinder->fHWAddressVector.size()*sizeof(AliHLTUInt16_t);
251 // cout<<"size of array: "<<sizeOfHWArray<<" number of entries"<<fKryptonClusterFinder->fHWAddressVector.size()<<endl;
253 if (dataOffsetBeforeHW+sizeOfHWArray>=size){
254 HLTFatal("Buffer too small too add the HW address list: %d of %d byte(s) already used",dataOffsetBeforeHW+sizeOfHWArray ,size);
258 AliHLTUInt16_t *outputHWPtr=(AliHLTUInt16_t*)(outputPtr+dataOffsetBeforeHW);
259 for(UInt_t hw=0;hw<fKryptonClusterFinder->fHWAddressVector.size();hw++){
260 *outputHWPtr = fKryptonClusterFinder->fHWAddressVector[hw];
264 AliHLTComponentBlockData bdHW;
265 FillBlockData( bdHW );
266 bdHW.fOffset = dataOffsetBeforeHW;
267 bdHW.fSize = sizeOfHWArray;
268 bdHW.fSpecification = iter->fSpecification;
269 bdHW.fDataType = kAliHLTDataTypeHwAddr16;
270 outputBlocks.push_back( bdHW );
272 size=dataOffsetBeforeHW+sizeOfHWArray;
282 int AliHLTTPCKryptonClusterFinderComponent::Configure(const char* arguments) {
283 // see header file for class documentation
286 if (!arguments) return iResult;
287 HLTInfo("parsing configuration string \'%s\'", arguments);
289 TString allArgs=arguments;
293 TObjArray* pTokens=allArgs.Tokenize(" ");
295 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
296 argument=((TObjString*)pTokens->At(i))->GetString();
297 if (argument.IsNull()) continue;
299 if (argument.CompareTo("-apply-noisemap")==0) {
300 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
301 HLTInfo("got \'-apply-noisemap\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
304 else if (argument.CompareTo("-plot-side-c")==0) {
305 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
306 HLTInfo("got \'-plot-side-c\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
309 else if (argument.CompareTo("-plot-side-a")==0) {
310 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
311 HLTInfo("got \'-plot-side-a\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
315 HLTError("unknown argument %s", argument.Data());
326 HLTError("missing parameter for argument %s", argument.Data());
333 int AliHLTTPCKryptonClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
335 // see header file for class documentation
336 const char* path="HLT/ConfigTPC";
337 if (cdbEntry) path=cdbEntry;
339 HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
340 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
342 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
344 HLTInfo("received configuration object: %s", pString->GetString().Data());
346 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
349 HLTError("can not fetch object \"%s\" from CDB", path);