Line data Source code
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: Timm Steinbeck, Matthias Richter *
8 : //* Developers: Kenneth Aamodt <kenneth.aamodt@student.uib.no> *
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 AliHLTTPCClusterFinderComponent.cxx
21 : @author Kenneth Aamodt <kenneth.aamodt@student.uib.no>
22 : @date
23 : @brief The TPC cluster finder processing component
24 : */
25 :
26 : #include "AliHLTTPCClusterFinderComponent.h"
27 : #include "AliHLTTPCDigitReaderUnpacked.h"
28 : #include "AliHLTTPCDigitReader32Bit.h"
29 : #include "AliHLTTPCClusterFinder.h"
30 : #include "AliHLTTPCSpacePointData.h"
31 : #include "AliHLTTPCClusterDataFormat.h"
32 : #include "AliHLTTPCGeometry.h"
33 : #include "AliHLTTPCClusters.h"
34 : #include "AliHLTTPCDefinitions.h"
35 : #include "AliGRPObject.h"
36 : #include "AliCDBEntry.h"
37 : #include "AliCDBManager.h"
38 : #include "AliTPCcalibDB.h"
39 : #include "AliTPCCalPad.h"
40 : #include "AliTPCParam.h"
41 : #include "AliTPCTransform.h"
42 : #include "AliHLTTPCClusterMCData.h"
43 :
44 : //#include "AliHLTTPCCAInputDataCompressorComponent.h"
45 : //#include "AliHLTTPCCADef.h"
46 :
47 : #include <cstdlib>
48 : #include <cerrno>
49 : #include "TString.h"
50 : #include "TObjString.h"
51 : #include "TObjArray.h"
52 : #include "AliCDBEntry.h"
53 : #include "AliCDBManager.h"
54 : #include "AliCDBStorage.h"
55 : #include "TGeoGlobalMagField.h"
56 : #include "AliGeomManager.h"
57 :
58 : #include <sys/time.h>
59 :
60 : using namespace std;
61 :
62 : /** ROOT macro for the implementation of ROOT specific class methods */
63 6 : ClassImp(AliHLTTPCClusterFinderComponent)
64 :
65 12 : AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(int mode)
66 : :
67 12 : fClusterFinder(NULL),
68 12 : fReader(NULL),
69 12 : fDeconvTime(kFALSE),
70 12 : fTS(0),
71 12 : fDeconvPad(kFALSE),
72 12 : fClusterDeconv(false),
73 12 : fXYClusterError(-1),
74 12 : fZClusterError(-1),
75 12 : fModeSwitch(mode),
76 12 : fUnsorted(1),
77 12 : fPatch(0),
78 12 : fGetActivePads(0),
79 12 : fFirstTimeBin(-1),
80 12 : fLastTimeBin(-1),
81 12 : fDoMC(kFALSE),
82 12 : fReleaseMemory( kFALSE ),
83 12 : fPublishRawClusters(kFALSE),
84 12 : fBenchmark("TPCClusterFinder")
85 60 : {
86 : // see header file for class documentation
87 : // or
88 : // refer to README to build package
89 : // or
90 : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
91 15 : if (fModeSwitch!=kClusterFinderPacked &&
92 9 : fModeSwitch!=kClusterFinderUnpacked &&
93 6 : fModeSwitch!=kClusterFinderDecoder &&
94 3 : fModeSwitch!=kClusterFinder32Bit) {
95 0 : HLTFatal("unknown digit reader type");
96 : }
97 24 : }
98 :
99 : AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
100 72 : {
101 : // see header file for class documentation
102 36 : }
103 :
104 : // Public functions to implement AliHLTComponent's interface.
105 : // These functions are required for the registration process
106 :
107 : const char* AliHLTTPCClusterFinderComponent::GetComponentID()
108 : {
109 : // see header file for class documentation
110 2028 : switch(fModeSwitch){
111 : case kClusterFinderPacked:
112 258 : return "TPCClusterFinderPacked";
113 : break;
114 : case kClusterFinderUnpacked:
115 255 : return "TPCClusterFinderUnpacked";
116 : break;
117 : case kClusterFinderDecoder:
118 252 : return "TPCClusterFinderDecoder";
119 : break;
120 : case kClusterFinder32Bit:
121 249 : return "TPCClusterFinder32Bit";
122 : break;
123 : }
124 0 : return "";
125 1014 : }
126 :
127 : void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
128 : {
129 : // see header file for class documentation
130 0 : list.clear();
131 0 : switch(fModeSwitch){
132 : case kClusterFinderUnpacked:
133 0 : list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
134 0 : break;
135 : case kClusterFinderDecoder: // deprecated, falling back to 32bit reader
136 : case kClusterFinderPacked: // deprecated, falling back to 32bit reader
137 : case kClusterFinder32Bit:
138 0 : list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
139 0 : break;
140 : }
141 0 : }
142 :
143 : AliHLTComponentDataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
144 : {
145 : // see header file for class documentation
146 0 : return kAliHLTMultipleDataType;
147 : }
148 :
149 : int AliHLTTPCClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
150 :
151 : {
152 : // see header file for class documentation
153 0 : tgtList.clear();
154 0 : tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
155 0 : tgtList.push_back(kAliHLTDataTypeHwAddr16);
156 : //tgtList.push_back(AliHLTTPCCADefinitions::fgkCompressedInputDataType);
157 0 : return tgtList.size();
158 : }
159 :
160 : void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
161 : {
162 : // see header file for class documentation
163 : // XXX TODO: Find more realistic values.
164 0 : constBase = 0;
165 0 : switch(fModeSwitch){
166 : case kClusterFinderUnpacked:
167 0 : inputMultiplier = 0.4;
168 0 : break;
169 : case kClusterFinderDecoder: // deprecated, falling back to 32bit reader
170 : case kClusterFinderPacked: // deprecated, falling back to 32bit reader
171 : case kClusterFinder32Bit:
172 0 : inputMultiplier = (6 * 0.4);
173 0 : break;
174 : }
175 0 : }
176 :
177 : AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
178 : {
179 : // see header file for class documentation
180 0 : return new AliHLTTPCClusterFinderComponent(fModeSwitch);
181 0 : }
182 :
183 : int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
184 : {
185 : // see header file for class documentation
186 0 : if ( fClusterFinder )
187 0 : return -EINPROGRESS;
188 :
189 : //Test if the OCDB entries used by AliTPCTransform is availible
190 0 : AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
191 : //
192 0 : if(!calib){
193 0 : HLTError("AliTPCcalibDB does not exist");
194 0 : return -ENOENT;
195 : }
196 :
197 0 : fTS = calib->GetTransform();
198 :
199 0 : calib->SetRun(GetRunNo());
200 0 : calib->UpdateRunInformations(GetRunNo());
201 0 : AliTPCCalPad * time0TPC = calib->GetPadTime0();
202 0 : if(!time0TPC){
203 0 : HLTError("OCDB entry TPC/Calib/PadTime0 (AliTPCcalibDB::GetPadTime0()) is not available.");
204 0 : return -ENOENT;
205 : }
206 :
207 0 : AliTPCParam * param = calib->GetParameters();
208 0 : if(!param){
209 0 : HLTError("OCDB entry TPC/Calib/Parameters (AliTPCcalibDB::GetParameters()) is not available.");
210 0 : return -ENOENT;
211 : }
212 :
213 : // Check field
214 0 : if (!TGeoGlobalMagField::Instance()) {
215 0 : HLTError("magnetic field not initialized, please set up TGeoGlobalMagField and AliMagF");
216 0 : return -ENODEV;
217 : }
218 0 : calib->SetExBField(GetBz());
219 :
220 0 : if(!AliGeomManager::GetGeometry()){
221 0 : AliGeomManager::LoadGeometry();
222 0 : }
223 :
224 0 : fClusterFinder = new AliHLTTPCClusterFinder();
225 :
226 0 : TObject* pOCDBEntry=LoadAndExtractOCDBObject("GRP/GRP/Data");
227 0 : AliGRPObject* pGRP=pOCDBEntry?dynamic_cast<AliGRPObject*>(pOCDBEntry):NULL;
228 0 : TString beamType;
229 0 : if (pGRP) {
230 0 : beamType=pGRP->GetBeamType();
231 0 : }
232 :
233 : // first configure the default
234 : int iResult = 0;
235 0 : TString cdbPath="HLT/ConfigTPC/";
236 0 : cdbPath+=GetComponentID();
237 0 : iResult=ConfigureFromCDBTObjString(cdbPath, beamType.Data());
238 :
239 : // configure from the command line parameters if specified
240 0 : if (iResult>=0 && argc>0)
241 0 : iResult=ConfigureFromArgumentString(argc, argv);
242 : // return iResult;
243 :
244 : /*
245 : Int_t iResult=0;
246 : TString configuration="";
247 : TString argument="";
248 : for (int i=0; i<argc && iResult>=0; i++) {
249 : argument=argv[i];
250 : if (!configuration.IsNull()) configuration+=" ";
251 : configuration+=argument;
252 : }
253 :
254 : if (!configuration.IsNull()) {
255 : iResult=Configure(configuration.Data());
256 : } else {
257 : iResult=Reconfigure(NULL, NULL);
258 : }
259 : */
260 :
261 : //Checking for conflicting arguments
262 0 : if(fClusterDeconv){
263 0 : if(fDeconvPad==kTRUE || fDeconvTime==kTRUE){
264 0 : HLTWarning("Conflicting arguments: argument 'pp-run' will be ignored.");
265 : }
266 : }
267 0 : if(fClusterFinder->GetOccupancyLimit()!=1.0 && fUnsorted){
268 0 : HLTWarning("Argument 'occupancy-limit' is deprecated when doing unsorted data reading.");
269 : }
270 0 : if(fGetActivePads==kTRUE && fUnsorted==kFALSE){
271 0 : HLTWarning("Argument '-active-pads' only work with unsorted data reading. Active pads list will not be produced.");
272 : }
273 :
274 :
275 : // Choose reader
276 0 : if (fModeSwitch==kClusterFinderPacked) {
277 0 : HLTWarning("AliHLTTPCDigitReaderPacked is deprecated, falling back to AliHLTTPCDigitReader32Bit");
278 : }
279 0 : else if(fModeSwitch==kClusterFinderDecoder){
280 0 : HLTWarning("AliHLTTPCDigitReaderPacked is deprecated, falling back to AliHLTTPCDigitReader32Bit");
281 : }
282 :
283 0 : if(fModeSwitch==kClusterFinderUnpacked){
284 : HLTDebug("using AliHLTTPCDigitReaderUnpacked");
285 0 : fReader = new AliHLTTPCDigitReaderUnpacked();
286 0 : if(fUnsorted==1){ fReader->SetUnsorted(kTRUE); }
287 0 : fClusterFinder->SetReader(fReader);
288 0 : }
289 0 : else if(fModeSwitch==kClusterFinder32Bit ||
290 0 : fModeSwitch==kClusterFinderPacked ||
291 0 : fModeSwitch==kClusterFinderDecoder){
292 : HLTDebug("using AliHLTTPCDigitReader32Bit");
293 0 : fReader = new AliHLTTPCDigitReader32Bit();
294 0 : fClusterFinder->SetReader(fReader);
295 0 : fClusterFinder->Set32BitFormat(kTRUE);
296 0 : }
297 : else{
298 0 : HLTFatal("No mode set for clusterfindercomponent");
299 : }
300 :
301 0 : if(fClusterDeconv){
302 0 : fClusterFinder->SetOccupancyLimit(1.0);
303 0 : }
304 :
305 0 : fClusterFinder->SetDeconv(fClusterDeconv);
306 0 : fClusterFinder->SetDeconvPad(fDeconvPad);
307 0 : fClusterFinder->SetDeconvTime(fDeconvPad);
308 0 : fClusterFinder->SetXYError( fXYClusterError );
309 0 : fClusterFinder->SetZError( fZClusterError );
310 0 : if ( (fXYClusterError>0) && (fZClusterError>0) ){
311 0 : fClusterFinder->SetCalcErr( false );
312 0 : }
313 :
314 0 : if(fFirstTimeBin>0){
315 0 : fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
316 0 : }
317 0 : if(fLastTimeBin>0 && fLastTimeBin>fFirstTimeBin && fLastTimeBin<=AliHLTTPCGeometry::GetNTimeBins()){
318 0 : fClusterFinder->SetLastTimeBin(fLastTimeBin);
319 0 : }
320 0 : fBenchmark.Reset();
321 0 : fBenchmark.SetTimer(0,"total");
322 0 : fBenchmark.SetTimer(1,"reco");
323 :
324 : return iResult;
325 0 : }
326 :
327 : int AliHLTTPCClusterFinderComponent::DoDeinit()
328 : {
329 : // see header file for class documentation
330 :
331 0 : if ( fClusterFinder )
332 0 : delete fClusterFinder;
333 0 : fClusterFinder = NULL;
334 :
335 0 : if ( fReader )
336 0 : delete fReader;
337 0 : fReader = NULL;
338 :
339 0 : return 0;
340 : }
341 :
342 : int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData,
343 : const AliHLTComponentBlockData* blocks,
344 : AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
345 : AliHLTUInt32_t& size,
346 : vector<AliHLTComponentBlockData>& outputBlocks )
347 : {
348 : // see header file for class documentation
349 : int iResult=0;
350 : //SG!!!
351 : //fDeconvTime = kTRUE;
352 : //fClusterFinder->SetDeconvTime(fDeconvTime);
353 : // fDeconvPad = kTRUE;
354 : //fClusterFinder->SetDeconvPad(fDeconvPad);
355 :
356 :
357 0 : fTS->SetCurrentTimeStamp(GetTimeStamp());
358 : //fTS->SetCurrentTimeStamp(0);
359 :
360 0 : if(fReader == NULL){
361 0 : HLTFatal("Digit reader not initialized, skipping HLT TPC cluster reconstruction.");
362 0 : size=0;
363 0 : return -ENODEV;
364 : }
365 :
366 0 : if(!IsDataEvent()){
367 0 : size=0;
368 0 : return 0;
369 : }
370 :
371 0 : fBenchmark.StartNewEvent();
372 0 : fBenchmark.Start(0);
373 :
374 : // == init iter (pointer to datablock)
375 : const AliHLTComponentBlockData* iter = NULL;
376 : unsigned long ndx;
377 :
378 : // == OUTdatatype pointer
379 : AliHLTTPCClusterData* outPtr;
380 :
381 : AliHLTUInt8_t* outBPtr;
382 : UInt_t offset, mysize, nSize, tSize = 0;
383 :
384 : outBPtr = outputPtr;
385 : outPtr = (AliHLTTPCClusterData*)outBPtr;
386 :
387 : Int_t slice, patch;
388 : unsigned long maxPoints, realPoints = 0;
389 :
390 0 : for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
391 : {
392 0 : iter = blocks+ndx;
393 : mysize = 0;
394 : offset = tSize;
395 :
396 : // Kenneth 16. July 2009
397 : // 32 byte is the size of the common data header (CDH)
398 : // this is introduced as a protection of empty files
399 : // normally when running with file publisher where
400 : // Timms script is used to create the missing files
401 0 : if(iter->fSize <= 32){
402 : continue;
403 : }
404 :
405 :
406 0 : if (fModeSwitch==0 || fModeSwitch==2 || fModeSwitch==3) {
407 : HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
408 : evtData.fEventID, evtData.fEventID,
409 : DataType2Text( iter->fDataType).c_str(),
410 : DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
411 :
412 0 : if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue;
413 :
414 : }
415 0 : else if(fModeSwitch==1){
416 : HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
417 : evtData.fEventID, evtData.fEventID,
418 : DataType2Text( iter->fDataType).c_str(),
419 : DataType2Text(AliHLTTPCDefinitions::fgkUnpackedRawDataType).c_str());
420 :
421 0 : if ( iter->fDataType != AliHLTTPCDefinitions::fgkUnpackedRawDataType ) continue;
422 :
423 : }
424 :
425 0 : fBenchmark.AddInput(iter->fSize);
426 :
427 0 : slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
428 0 : patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
429 :
430 0 : if(fUnsorted){
431 0 : fClusterFinder->SetUnsorted(fUnsorted);
432 0 : fClusterFinder->SetPatch(patch);
433 0 : }
434 :
435 0 : outPtr = (AliHLTTPCClusterData*)outBPtr;
436 :
437 0 : maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
438 :
439 0 : fClusterFinder->SetFillRawClusters(fPublishRawClusters);
440 0 : fClusterFinder->InitSlice( slice, patch, maxPoints );
441 0 : fClusterFinder->SetOutputArray( (AliHLTTPCSpacePointData*)outPtr->fSpacePoints );
442 :
443 0 : fBenchmark.Start(1);
444 :
445 0 : if(fUnsorted){
446 0 : if(fGetActivePads){
447 0 : fClusterFinder->SetDoPadSelection(kTRUE);
448 0 : }
449 0 : if(fDeconvTime){
450 0 : fClusterFinder->ReadDataUnsortedDeconvoluteTime(iter->fPtr, iter->fSize);
451 0 : }
452 : else{
453 0 : fClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize);
454 : }
455 :
456 0 : fClusterFinder->FindClusters();
457 0 : }
458 : else{
459 0 : fClusterFinder->Read(iter->fPtr, iter->fSize );
460 0 : fClusterFinder->ProcessDigits();
461 : }
462 0 : fBenchmark.Stop(1);
463 :
464 0 : fReader->Reset();
465 :
466 0 : realPoints = fClusterFinder->GetNumberOfClusters();
467 :
468 0 : outPtr->fSpacePointCnt = realPoints;
469 0 : nSize = sizeof(AliHLTTPCSpacePointData)*realPoints;
470 0 : mysize += nSize+sizeof(AliHLTTPCClusterData);
471 :
472 0 : Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints",
473 : "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
474 0 : realPoints, slice, patch,AliHLTTPCGeometry::GetFirstRow( patch ) , AliHLTTPCGeometry::GetLastRow( patch ) );
475 0 : AliHLTComponentBlockData bd;
476 0 : FillBlockData( bd );
477 0 : bd.fOffset = offset;
478 0 : bd.fSize = mysize;
479 0 : bd.fSpecification = iter->fSpecification;
480 0 : bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
481 0 : outputBlocks.push_back( bd );
482 :
483 0 : fBenchmark.AddOutput(bd.fSize);
484 :
485 0 : tSize += mysize;
486 0 : outBPtr += mysize;
487 : outPtr = (AliHLTTPCClusterData*)outBPtr;
488 :
489 :
490 0 : if ( tSize > size )
491 : {
492 0 : Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
493 : "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
494 : tSize, size );
495 : iResult=-ENOSPC;
496 0 : break;
497 : }
498 :
499 0 : if(fUnsorted && fGetActivePads){
500 0 : Int_t maxNumberOfHW=(Int_t)((size-tSize)/sizeof(AliHLTUInt16_t)-1);
501 0 : AliHLTUInt16_t* outputHWPtr= (AliHLTUInt16_t*)(outputPtr+tSize);
502 0 : Int_t nHWAdd = fClusterFinder->FillHWAddressList(outputHWPtr, maxNumberOfHW);
503 :
504 0 : AliHLTComponentBlockData bdHW;
505 0 : FillBlockData( bdHW );
506 0 : bdHW.fOffset = tSize ;
507 0 : bdHW.fSize = nHWAdd*sizeof(AliHLTUInt16_t);
508 0 : bdHW.fSpecification = iter->fSpecification;
509 0 : bdHW.fDataType = kAliHLTDataTypeHwAddr16;
510 0 : outputBlocks.push_back( bdHW );
511 :
512 0 : fBenchmark.AddOutput(bdHW.fSize);
513 0 : tSize+=nHWAdd*sizeof(AliHLTUInt16_t);
514 0 : }
515 :
516 : /*
517 : { // compressed output for the CA tracker
518 :
519 : AliHLTUInt32_t dSize = 0;
520 :
521 : int ret = AliHLTTPCCAInputDataCompressorComponent::Compress( (AliHLTTPCClusterData*)( outputPtr + bd.fOffset ),
522 : size - tSize,
523 : outputPtr+tSize,
524 : dSize );
525 :
526 : if ( ret!=0 || tSize + dSize > size )
527 : {
528 : Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
529 : "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
530 : tSize + dSize, size );
531 : iResult=-ENOSPC;
532 : break;
533 : }
534 :
535 : AliHLTComponentBlockData bdCompressed;
536 : FillBlockData( bdCompressed );
537 : bdCompressed.fOffset = tSize ;
538 : bdCompressed.fSize = dSize;
539 : bdCompressed.fSpecification = iter->fSpecification;
540 : bdCompressed.fDataType = AliHLTTPCCADefinitions::fgkCompressedInputDataType;
541 : outputBlocks.push_back( bdCompressed );
542 :
543 : tSize += dSize;
544 : outBPtr += dSize;
545 : outPtr = (AliHLTTPCClusterData*)outBPtr;
546 : }
547 : */
548 :
549 0 : if(fDoMC){
550 0 : Int_t maxNumberOfClusterMCInfo = (Int_t)((size-tSize-sizeof(AliHLTTPCClusterMCData))/sizeof(AliHLTTPCClusterMCLabel)-1);
551 0 : if( maxNumberOfClusterMCInfo>0 ){
552 0 : AliHLTTPCClusterMCData* outputMCInfo= (AliHLTTPCClusterMCData*)(outputPtr+tSize);
553 0 : outputMCInfo->fCount = fClusterFinder->FillOutputMCInfo(outputMCInfo->fLabels, maxNumberOfClusterMCInfo);
554 :
555 0 : AliHLTComponentBlockData bdMCInfo;
556 0 : FillBlockData( bdMCInfo );
557 0 : bdMCInfo.fOffset = tSize;
558 0 : bdMCInfo.fSize = sizeof(AliHLTTPCClusterMCData)+outputMCInfo->fCount*sizeof(AliHLTTPCClusterMCLabel);
559 0 : bdMCInfo.fSpecification = iter->fSpecification;
560 0 : bdMCInfo.fDataType = AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo;
561 0 : outputBlocks.push_back( bdMCInfo );
562 0 : fBenchmark.AddOutput(bdMCInfo.fSize);
563 0 : tSize+=bdMCInfo.fSize;
564 0 : }
565 0 : }
566 :
567 0 : if (fPublishRawClusters) {
568 0 : AliHLTTPCRawClusterData* outputRaw= (AliHLTTPCRawClusterData*)(outputPtr+tSize);
569 0 : outputRaw->fCount = fClusterFinder->FillOutputRaw(outputRaw->fClusters, size-tSize);
570 :
571 0 : AliHLTComponentBlockData bdRawClusters;
572 0 : FillBlockData( bdRawClusters );
573 0 : bdRawClusters.fOffset = tSize;
574 0 : bdRawClusters.fSize = sizeof(AliHLTTPCRawClusterData)+outputRaw->fCount*sizeof(AliHLTTPCRawCluster);
575 0 : bdRawClusters.fSpecification = iter->fSpecification;
576 0 : bdRawClusters.fDataType = AliHLTTPCDefinitions::fgkRawClustersDataType;
577 0 : outputBlocks.push_back( bdRawClusters );
578 0 : fBenchmark.AddOutput(bdRawClusters.fSize);
579 0 : tSize+=bdRawClusters.fSize;
580 0 : }
581 0 : }
582 :
583 0 : if (iResult>=0)
584 0 : size = tSize;
585 :
586 0 : fBenchmark.Stop(0);
587 0 : HLTInfo(fBenchmark.GetStatistics());
588 : return iResult;
589 0 : }
590 :
591 : int AliHLTTPCClusterFinderComponent::ScanConfigurationArgument(int argc, const char** argv){
592 :
593 : // see header file for class documentation
594 :
595 0 : if (argc<=0) return 0;
596 : int i=0;
597 0 : TString argument=argv[i];
598 :
599 0 : if (argument.CompareTo("-solenoidBz")==0){
600 0 : if (++i>=argc) return -EPROTO;
601 0 : HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
602 0 : return 2;
603 : }
604 :
605 0 : if (argument.CompareTo("-update-calibdb")==0 || argument.CompareTo("-update-transform")==0 ){
606 0 : if(fClusterFinder->UpdateCalibDB()){
607 : HLTDebug("CalibDB and offline transform successfully updated.");
608 : }
609 : else{
610 0 : HLTError("CalibDB could not be updated.");
611 : }
612 0 : return 1;
613 : }
614 :
615 0 : if (argument.CompareTo("-deconvolute-time")==0){
616 : HLTDebug("Switching on deconvolution in time direction.");
617 0 : fDeconvTime = kTRUE;
618 0 : fClusterFinder->SetDeconvTime(fDeconvTime);
619 0 : return 1;
620 : }
621 :
622 0 : if (argument.CompareTo("-deconvolute-pad")==0){
623 : HLTDebug("Switching on deconvolution in pad direction.");
624 0 : fDeconvPad = kTRUE;
625 0 : fClusterFinder->SetDeconvPad(fDeconvPad);
626 0 : return 1;
627 : }
628 :
629 0 : if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
630 0 : HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
631 : /*
632 : if (++i>=argc) return -EPROTO;
633 : argument=argv[i];
634 : AliHLTTPCGeometry::SetNTimeBins(argument.Atoi());
635 : fClusterFinder->UpdateLastTimeBin();
636 : HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCGeometry::GetNTimeBins(), AliHLTTPCGeometry::GetZWidth());
637 : return 2;
638 : */
639 0 : if(argument.CompareTo("timebins")==0){
640 0 : HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
641 : }
642 0 : return 2;
643 : }
644 :
645 0 : if (argument.CompareTo("-first-timebin")==0){
646 0 : if (++i>=argc) return -EPROTO;
647 0 : argument=argv[i];
648 0 : fFirstTimeBin = argument.Atoi();
649 0 : if(fFirstTimeBin>=0){
650 : HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
651 0 : fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
652 0 : }
653 : else{
654 0 : HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
655 : }
656 0 : return 2;
657 : }
658 :
659 0 : if (argument.CompareTo("-last-timebin")==0){
660 0 : if (++i>=argc) return -EPROTO;
661 0 : argument=argv[i];
662 0 : fLastTimeBin = argument.Atoi();
663 0 : if(fLastTimeBin<AliHLTTPCGeometry::GetNTimeBins()){
664 : HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
665 : }
666 : else{
667 0 : HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCGeometry::GetNTimeBins());
668 : }
669 0 : return 2;
670 : }
671 :
672 0 : if (argument.CompareTo("-sorted")==0) {
673 0 : fUnsorted=0;
674 : HLTDebug("Swithching unsorted off.");
675 0 : fClusterFinder->SetUnsorted(0);
676 0 : return 1;
677 : }
678 :
679 0 : if (argument.CompareTo("-do-mc")==0) {
680 0 : fDoMC=kTRUE;
681 0 : fClusterFinder->SetDoMC(fDoMC);
682 : HLTDebug("Setting fDoMC to true.");
683 0 : return 1;
684 : }
685 0 : if (argument.CompareTo("-release-memory")==0) {
686 0 : fReleaseMemory=kTRUE;
687 0 : fClusterFinder->SetReleaseMemory( fReleaseMemory );
688 : HLTDebug("Setting fReleaseMemory to true.");
689 0 : return 1;
690 : }
691 0 : if (argument.CompareTo("-publish-raw")==0) {
692 0 : fPublishRawClusters=kTRUE;
693 0 : fClusterFinder->SetFillRawClusters(fPublishRawClusters);
694 0 : return 1;
695 : }
696 :
697 0 : if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
698 0 : if(argument.CompareTo("activepads" )==0){
699 0 : HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
700 : }
701 : HLTDebug("Switching on ActivePads");
702 0 : fGetActivePads = 1;
703 0 : fClusterFinder->SetDoPadSelection(kTRUE);
704 0 : return 1;
705 : }
706 :
707 0 : if (argument.CompareTo("-occupancy-limit")==0 || argument.CompareTo("occupancy-limit")==0){
708 0 : if(argument.CompareTo("occupancy-limit" )==0){
709 0 : HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
710 : }
711 0 : if (++i>=argc) return -EPROTO;
712 0 : argument=argv[i];
713 0 : fClusterFinder->SetOccupancyLimit(argument.Atof());
714 : HLTDebug("Occupancy limit set to occulimit %f", argument.Atof());
715 0 : return 2;
716 : }
717 :
718 0 : if (argument.CompareTo("rawreadermode")==0){
719 0 : if (++i>=argc) return -EPROTO;
720 0 : HLTWarning("Argument 'rawreadermode' is deprecated");
721 0 : return 2;
722 : }
723 :
724 0 : if (argument.CompareTo("pp-run")==0){
725 0 : HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
726 0 : fClusterDeconv = false;
727 0 : return 1;
728 : }
729 :
730 0 : if (argument.CompareTo("adc-threshold" )==0){
731 0 : if (++i>=argc) return -EPROTO;
732 0 : HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
733 0 : return 2;
734 : }
735 :
736 0 : if (argument.CompareTo("oldrcuformat" )==0){
737 0 : if (++i>=argc) return -EPROTO;
738 0 : HLTWarning("Argument 'oldrcuformat' is deprecated.");
739 0 : return 2;
740 : }
741 :
742 0 : if (argument.CompareTo("unsorted" )==0 || argument.CompareTo("-unsorted" )==0){
743 0 : HLTWarning("Argument is obsolete, unsorted reading is default.");
744 : // fClusterFinder->SetUnsorted(1);
745 0 : return 1;
746 : }
747 0 : if (argument.CompareTo("nsigma-threshold")==0){
748 0 : if (++i>=argc) return -EPROTO;
749 0 : HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
750 0 : return 2;
751 : }
752 :
753 : // unknown argument
754 0 : return -EINVAL;
755 0 : }
756 :
757 : int AliHLTTPCClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
758 : {
759 : // see header file for class documentation
760 :
761 0 : TString cdbPath;
762 0 : if (cdbEntry) {
763 0 : cdbPath=cdbEntry;
764 : } else {
765 0 : cdbPath="HLT/ConfigTPC/";
766 0 : cdbPath+=GetComponentID();
767 : }
768 :
769 0 : return ConfigureFromCDBTObjString(cdbPath.Data());
770 :
771 : /*
772 : int iResult=0;
773 :
774 : const char* path="HLT/ConfigTPC/ClusterFinderComponent";
775 : if (cdbEntry) path=cdbEntry;
776 : if (path) {
777 : HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
778 : AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);//,GetRunNo());
779 : if (pEntry) {
780 : TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
781 : if (pString) {
782 : HLTInfo("received configuration object: %s", pString->GetString().Data());
783 : iResult = Configure(pString->GetString().Data());
784 : } else {
785 : HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
786 : }
787 : } else {
788 : HLTError("can not fetch object \"%s\" from CDB", path);
789 : }
790 : }
791 : return iResult;
792 : */
793 0 : }
794 :
795 : int AliHLTTPCClusterFinderComponent::Configure(const char* arguments){
796 : // see header file for class documentation
797 : int iResult=0;
798 0 : if (!arguments) return iResult;
799 :
800 0 : TString allArgs=arguments;
801 0 : TString argument;
802 : int bMissingParam=0;
803 :
804 0 : TObjArray* pTokens=allArgs.Tokenize(" ");
805 0 : if (pTokens) {
806 :
807 0 : for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
808 0 : argument=((TObjString*)pTokens->At(i))->GetString();
809 :
810 0 : if (argument.IsNull()) continue;
811 :
812 : // -- deconvolute-time option
813 0 : if (argument.CompareTo("-deconvolute-time")==0){
814 : HLTDebug("Switching on deconvolution in time direction.");
815 0 : fDeconvTime = kTRUE;
816 0 : fClusterFinder->SetDeconvTime(fDeconvTime);
817 0 : }
818 0 : else if (argument.CompareTo("-deconvolute-pad")==0){
819 : HLTDebug("Switching on deconvolution in pad direction.");
820 0 : fDeconvPad = kTRUE;
821 0 : fClusterFinder->SetDeconvPad(fDeconvPad);
822 0 : }
823 0 : else if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
824 0 : HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
825 : /*
826 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
827 : AliHLTTPCGeometry::SetNTimeBins(((TObjString*)pTokens->At(i))->GetString().Atoi());
828 : fClusterFinder->UpdateLastTimeBin();
829 : HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCGeometry::GetNTimeBins(), AliHLTTPCGeometry::GetZWidth());
830 : */
831 0 : if(argument.CompareTo("timebins")==0){
832 0 : HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
833 : }
834 :
835 : }
836 0 : else if (argument.CompareTo("-first-timebin")==0){
837 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
838 0 : fFirstTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
839 0 : if(fFirstTimeBin>=0){
840 : HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
841 0 : fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
842 0 : }
843 : else{
844 0 : HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
845 : }
846 : }
847 0 : else if (argument.CompareTo("-last-timebin")==0){
848 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
849 0 : fLastTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
850 0 : if(fLastTimeBin<AliHLTTPCGeometry::GetNTimeBins()){
851 : HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
852 : }
853 : else{
854 0 : HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCGeometry::GetNTimeBins());
855 : }
856 : }
857 0 : else if (argument.CompareTo("-sorted")==0) {
858 0 : fUnsorted=0;
859 : HLTDebug("Swithching unsorted off.");
860 0 : fClusterFinder->SetUnsorted(0);
861 0 : }
862 0 : else if (argument.CompareTo("-do-mc")==0) {
863 0 : fDoMC=kTRUE;
864 0 : fClusterFinder->SetDoMC(fDoMC);
865 0 : HLTInfo("Setting fDoMC to true.");
866 : }
867 0 : else if (argument.CompareTo("-release-memory")==0) {
868 0 : fReleaseMemory = kTRUE;
869 0 : fClusterFinder->SetReleaseMemory( kTRUE );
870 0 : HLTInfo("Setting fReleaseMemory to true.");
871 : }
872 0 : else if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
873 0 : if(argument.CompareTo("activepads" )==0){
874 0 : HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
875 : }
876 : HLTDebug("Switching on ActivePads");
877 0 : fGetActivePads = 1;
878 0 : fClusterFinder->SetDoPadSelection(kTRUE);
879 0 : }
880 0 : else if (argument.CompareTo("-occupancy-limit")==0 || argument.CompareTo("occupancy-limit")==0){
881 0 : if(argument.CompareTo("occupancy-limit" )==0){
882 0 : HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
883 : }
884 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
885 0 : fClusterFinder->SetOccupancyLimit(((TObjString*)pTokens->At(i))->GetString().Atof());
886 : HLTDebug("Occupancy limit set to occulimit %f", ((TObjString*)pTokens->At(i))->GetString().Atof());
887 0 : }
888 0 : else if (argument.CompareTo("rawreadermode")==0){
889 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
890 0 : HLTWarning("Argument 'rawreadermode' is deprecated");
891 : }
892 0 : else if (argument.CompareTo("pp-run")==0){
893 0 : HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
894 0 : fClusterDeconv = false;
895 0 : }
896 0 : else if (argument.CompareTo("adc-threshold" )==0){
897 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
898 0 : HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
899 : }
900 0 : else if (argument.CompareTo("oldrcuformat" )==0){
901 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
902 0 : HLTWarning("Argument 'oldrcuformat' is deprecated.");
903 : }
904 0 : else if (argument.CompareTo("unsorted" )==0){
905 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
906 : HLTDebug("Using unsorted reading.");
907 0 : fClusterFinder->SetUnsorted(1);
908 0 : }
909 0 : else if (argument.CompareTo("nsigma-threshold")==0){
910 0 : if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
911 0 : HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
912 : }
913 0 : else if (argument.CompareTo("-update-calibdb")==0){
914 0 : fClusterFinder->UpdateCalibDB();
915 : }
916 : else {
917 0 : HLTError("unknown argument %s", argument.Data());
918 : iResult=-EINVAL;
919 0 : break;
920 : }
921 : }
922 0 : delete pTokens;
923 : }
924 0 : if (bMissingParam) {
925 0 : HLTError("missing parameter for argument %s", argument.Data());
926 : iResult=-EINVAL;
927 0 : }
928 : return iResult;
929 0 : }
930 :
931 : void AliHLTTPCClusterFinderComponent::GetOCDBObjectDescription( TMap* const targetMap){
932 : // Get a list of OCDB object description needed for the particular component
933 :
934 0 : if (!targetMap) return;
935 :
936 : // OCDB entries for component arguments
937 0 : switch(fModeSwitch){
938 : case kClusterFinderPacked:
939 : // deprecated but kept for a short while to support porting to release
940 0 : targetMap->Add(new TObjString("HLT/ConfigTPC/TPCClusterFinderPacked"), new TObjString("component arguments, empty at the moment"));
941 0 : break;
942 : case kClusterFinderUnpacked:
943 0 : targetMap->Add(new TObjString("HLT/ConfigTPC/TPCClusterFinderUnpacked"), new TObjString("component arguments, empty at the moment"));
944 0 : break;
945 : case kClusterFinderDecoder:
946 : // deprecated but kept for a short while to support porting to release
947 0 : targetMap->Add(new TObjString("HLT/ConfigTPC/TPCClusterFinderDecoder"), new TObjString("component arguments, empty at the moment"));
948 0 : break;
949 : case kClusterFinder32Bit:
950 0 : targetMap->Add(new TObjString("HLT/ConfigTPC/TPCClusterFinder32Bit"), new TObjString("component arguments, empty at the moment"));
951 0 : break;
952 : }
953 :
954 : // OCDB entries to be fetched by the TAXI (access via the AliTPCcalibDB class)
955 0 : targetMap->Add(new TObjString("TPC/Calib/Parameters"), new TObjString("unknown content"));
956 0 : targetMap->Add(new TObjString("TPC/Calib/TimeDrift"), new TObjString("drift velocity calibration"));
957 0 : targetMap->Add(new TObjString("TPC/Calib/Temperature"), new TObjString("temperature map"));
958 0 : targetMap->Add(new TObjString("TPC/Calib/PadGainFactor"), new TObjString("gain factor pad by pad"));
959 0 : targetMap->Add(new TObjString("TPC/Calib/ClusterParam"), new TObjString("cluster parameters"));
960 :
961 : // OCDB entries needed to be fetched by the Pendolino
962 0 : targetMap->Add(new TObjString("TPC/Calib/AltroConfig"), new TObjString("contains the altro config, e.g. info about the L0 trigger timing"));
963 0 : targetMap->Add(new TObjString("GRP/CTP/CTPtiming"), new TObjString("content used in the cluster coordinate transformation in relation to the L0 trigger timing"));
964 :
965 : // OCDB entries necessary for replaying data on the HLT cluster
966 0 : targetMap->Add(new TObjString("GRP/GRP/Data"), new TObjString("contains magnetic field info"));
967 :
968 : // OCDB entries needed to suppress fatals/errors/warnings during reconstruction
969 0 : targetMap->Add(new TObjString("TPC/Calib/PadTime0"), new TObjString("time0 offset pad by pad"));
970 0 : targetMap->Add(new TObjString("TPC/Calib/PadNoise"), new TObjString("pad noise values"));
971 0 : targetMap->Add(new TObjString("TPC/Calib/Pedestals"), new TObjString("pedestal info"));
972 0 : targetMap->Add(new TObjString("TPC/Calib/Pulser"), new TObjString("pulser info"));
973 0 : targetMap->Add(new TObjString("TPC/Calib/CE"), new TObjString("CE laser calibration result"));
974 0 : targetMap->Add(new TObjString("TPC/Calib/Raw"), new TObjString("unknown content"));
975 0 : targetMap->Add(new TObjString("TPC/Calib/QA"), new TObjString("not important"));
976 0 : targetMap->Add(new TObjString("TPC/Calib/Mapping"), new TObjString("unknown content"));
977 0 : targetMap->Add(new TObjString("TPC/Calib/Goofie"), new TObjString("Goofie values, not used at the moment (05.03.2010)"));
978 0 : targetMap->Add(new TObjString("TPC/Calib/HighVoltage"), new TObjString("high voltage values, not used"));
979 0 : targetMap->Add(new TObjString("TPC/Calib/Ref"), new TObjString("unknown content"));
980 0 : }
|