]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/ITS/AliHLTITSClusterFinderComponent.cxx
debug output removed
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSClusterFinderComponent.cxx
CommitLineData
6b7742a2 1// $Id$
2//**************************************************************************
3//* This file is property of and copyright by the ALICE HLT Project *
4//* ALICE Experiment at CERN, All rights reserved. *
5//* *
29d7dbc9 6//* Primary Authors: Gaute Ovrebekk <st05886@alf.uib.no> *
6b7742a2 7//* for The ALICE HLT Project. *
8//* *
9//* Permission to use, copy, modify and distribute this software and its *
10//* documentation strictly for non-commercial purposes is hereby granted *
11//* without fee, provided that the above copyright notice appears in all *
12//* copies and that both the copyright notice and this permission notice *
13//* appear in the supporting documentation. The authors make no claims *
14//* about the suitability of this software for any purpose. It is *
15//* provided "as is" without express or implied warranty. *
16//**************************************************************************
17
29d7dbc9 18/// @file AliHLTITSClusterFinderComponent.cxx
19/// @author Gaute Ovrebekk <st05886@alf.uib.no>
20/// @date
21/// @brief Component to run offline clusterfinders
22///
6b7742a2 23
24#if __GNUC__>= 3
25using namespace std;
26#endif
27
28#include "AliHLTITSClusterFinderComponent.h"
29
30#include "AliCDBEntry.h"
31#include "AliCDBManager.h"
6b7742a2 32#include "AliITSgeomTGeo.h"
33#include "AliITSRecPoint.h"
34#include "AliHLTITSSpacePointData.h"
35#include "AliHLTITSClusterDataFormat.h"
36#include <AliHLTDAQ.h>
37#include "AliGeomManager.h"
060f29ad 38#include "AliITSRecoParam.h"
39#include "AliITSReconstructor.h"
3f61e9ce 40#include "AliHLTITSClusterFinderSPD.h"
a2a2a7ce 41#include "AliHLTITSClusterFinderSSD.h"
6eb9783a 42#include "TMap.h"
01ef1bd4 43#include "AliITSRecPointContainer.h"
29d7dbc9 44#include "AliRunLoader.h"
45#include "AliLoader.h"
6b7742a2 46
47#include <cstdlib>
48#include <cerrno>
9f2cda35 49#include "TFile.h"
6b7742a2 50#include "TString.h"
51#include "TObjString.h"
52#include <sys/time.h>
53
54/** ROOT macro for the implementation of ROOT specific class methods */
55ClassImp(AliHLTITSClusterFinderComponent);
56
57AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
58 :
59 fModeSwitch(mode),
a2a2a7ce 60 fInputDataType(kAliHLTVoidDataType),
61 fOutputDataType(kAliHLTVoidDataType),
62 fUseOfflineFinder(0),
6b7742a2 63 fNModules(0),
64 fId(0),
65 fNddl(0),
6b7742a2 66 fRawReader(NULL),
67 fDettype(NULL),
68 fgeom(NULL),
3f61e9ce 69 fgeomInit(NULL),
a2a2a7ce 70 fSPD(NULL),
618f422f 71 fSSD(NULL),
72 tD(NULL),
73 tR(NULL),
01ef1bd4 74 fSPDNModules(0),
75 fSDDNModules(0),
76 fSSDNModules(0),
8e5edf3c 77 fFirstModule(0),
78 fLastModule(0),
79 fnClusters(0),
57a4102f 80 fclusters(),
29d7dbc9 81 fBenchmark(GetComponentID()),
82 fOutputSizeOffset(0),
83 fInputMultiplierDigits(20),
84 fpLoader(NULL)
6b7742a2 85{
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
a2a2a7ce 91
92 switch(fModeSwitch){
93 case kClusterFinderSPD:
94 fInputDataType = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSPD;
95 fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD;
96 break;
97 case kClusterFinderSDD:
98 fInputDataType = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD;
99 fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD;
100 break;
101 case kClusterFinderSSD:
102 fInputDataType = kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSSD;
103 fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD;
104 break;
618f422f 105 case kClusterFinderDigits:
59b3dd4b 106 fInputDataType = kAliHLTDataTypeAliTreeD|kAliHLTDataOriginITS;
618f422f 107 fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITS;
108 break;
a2a2a7ce 109 default:
6b7742a2 110 HLTFatal("unknown cluster finder");
111 }
112}
113
3f61e9ce 114AliHLTITSClusterFinderComponent::~AliHLTITSClusterFinderComponent()
115{
6b7742a2 116 // see header file for class documentation
3f61e9ce 117 delete fRawReader;
118 delete fDettype;
119 delete fgeomInit;
120 delete fSPD;
a2a2a7ce 121 delete fSSD;
6b7742a2 122}
123
124// Public functions to implement AliHLTComponent's interface.
125// These functions are required for the registration process
126
127const char* AliHLTITSClusterFinderComponent::GetComponentID()
128{
129 // see header file for class documentation
130 switch(fModeSwitch){
131 case kClusterFinderSPD:
132 return "ITSClusterFinderSPD";
133 break;
134 case kClusterFinderSDD:
135 return "ITSClusterFinderSDD";
136 break;
137 case kClusterFinderSSD:
138 return "ITSClusterFinderSSD";
139 break;
618f422f 140 case kClusterFinderDigits:
141 return "ITSClusterFinderDigits";
142 break;
6b7742a2 143 }
144 return "";
145}
146
a2a2a7ce 147void AliHLTITSClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
148{
6b7742a2 149 // see header file for class documentation
150 list.clear();
a2a2a7ce 151 list.push_back( fInputDataType );
6b7742a2 152}
153
a2a2a7ce 154AliHLTComponentDataType AliHLTITSClusterFinderComponent::GetOutputDataType()
155{
6b7742a2 156 // see header file for class documentation
a2a2a7ce 157 return fOutputDataType;
6b7742a2 158}
159
160void AliHLTITSClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
161 // see header file for class documentation
29d7dbc9 162 constBase = fOutputSizeOffset;
dc549b2c 163 switch(fModeSwitch){
164 case kClusterFinderDigits:
29d7dbc9 165 inputMultiplier = fInputMultiplierDigits;
dc549b2c 166 break;
167 case kClusterFinderSPD:
168 case kClusterFinderSDD:
169 case kClusterFinderSSD:
170 default:
171 inputMultiplier = 20;
172 }
6b7742a2 173}
174
175AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() {
176 // see header file for class documentation
177 return new AliHLTITSClusterFinderComponent(fModeSwitch);
178}
179
1ea949fd 180Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) {
6b7742a2 181 // see header file for class documentation
57a4102f 182 fBenchmark.Reset();
183 fBenchmark.SetTimer(0,"total");
184 fBenchmark.SetTimer(1,"reco");
185
6b7742a2 186 if(fModeSwitch==kClusterFinderSPD) {
187 HLTDebug("using ClusterFinder for SPD");
d293cef8 188 //fNModules=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2);
6b7742a2 189 fId=AliHLTDAQ::DdlIDOffset("ITSSPD");
190 fNddl=AliHLTDAQ::NumberOfDdls("ITSSPD");
191 }
192 else if(fModeSwitch==kClusterFinderSDD) {
193 HLTDebug("using ClusterFinder for SDD");
d293cef8 194 //fNModules=AliITSgeomTGeo::GetNDetectors(3)*AliITSgeomTGeo::GetNLadders(3) + AliITSgeomTGeo::GetNDetectors(4)*AliITSgeomTGeo::GetNLadders(4);
6b7742a2 195 fId=AliHLTDAQ::DdlIDOffset("ITSSDD");
196 fNddl=AliHLTDAQ::NumberOfDdls("ITSSDD");
197 }
198 else if(fModeSwitch==kClusterFinderSSD) {
199 HLTDebug("using ClusterFinder for SSD");
d293cef8 200 //fNModules=AliITSgeomTGeo::GetNDetectors(5)*AliITSgeomTGeo::GetNLadders(5) + AliITSgeomTGeo::GetNDetectors(6)*AliITSgeomTGeo::GetNLadders(6);
6b7742a2 201 fId=AliHLTDAQ::DdlIDOffset("ITSSSD");
202 fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD");
203 }
ec0e5f0f 204 else if(fModeSwitch==kClusterFinderDigits) {
8e5edf3c 205 tR = new TTree();
618f422f 206 }
6b7742a2 207 else{
208 HLTFatal("No mode set for clusterfindercomponent");
209 }
210
060f29ad 211 //Removed the warning for loading default RecoParam in HLT
212 AliITSRecoParam *par = AliITSRecoParam::GetLowFluxParam();
213 AliITSReconstructor *rec = new AliITSReconstructor();
214 rec->SetRecoParam(par);
215
6b7742a2 216 AliCDBManager* man = AliCDBManager::Instance();
217 if (!man->IsDefaultStorageSet()){
218 HLTError("Default CDB storage has not been set !");
219 return -ENOENT;
220 }
221
222 if(AliGeomManager::GetGeometry()==NULL){
223 AliGeomManager::LoadGeometry();
224 }
3f61e9ce 225
3384df26 226 fgeomInit = new AliITSInitGeometry();
227 //fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2);
6b7742a2 228 //fgeomInit->InitAliITSgeom(fgeom);
229 fgeom = fgeomInit->CreateAliITSgeom();
3f61e9ce 230
d293cef8 231 fNModules = fgeom->GetIndexMax();
01ef1bd4 232 Int_t modperlay[6];
233 for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
234 fSPDNModules=modperlay[0]+modperlay[1];
235 fSDDNModules=modperlay[2]+modperlay[3];
236 fSSDNModules=modperlay[4]+modperlay[5];
237
238 if(fModeSwitch==kClusterFinderSPD) {
239 fFirstModule=0;
240 fLastModule=fSPDNModules;
241 }
242 else if(fModeSwitch==kClusterFinderSDD) {
243 fFirstModule=fSPDNModules;
244 fLastModule=fFirstModule + fSDDNModules;
245 }
246 else if(fModeSwitch==kClusterFinderSSD) {
247 fFirstModule=fSPDNModules + fSDDNModules;
248 fLastModule=fFirstModule + fSSDNModules;
249 }
250
6b7742a2 251 //set dettype
252 fDettype = new AliITSDetTypeRec();
3f61e9ce 253 fDettype->SetITSgeom(fgeom);
6b7742a2 254 fDettype->SetDefaults();
86e746ed 255 fDettype->SetDefaultClusterFindersV2(kTRUE);
256
6b7742a2 257 if ( fRawReader )
258 return -EINPROGRESS;
259
260 fRawReader = new AliRawReaderMemory();
3f61e9ce 261 fSPD = new AliHLTITSClusterFinderSPD( fDettype );
a2a2a7ce 262 fSSD = new AliHLTITSClusterFinderSSD( fDettype, fRawReader );
6b7742a2 263
1ea949fd 264 TString arguments = "";
265 for ( int i = 0; i < argc; i++ ) {
266 if ( !arguments.IsNull() ) arguments += " ";
267 arguments += argv[i];
268 }
269
618f422f 270 tD = NULL;
8e5edf3c 271 //tR = NULL;
618f422f 272
1ea949fd 273 return Configure( arguments.Data() );
6b7742a2 274}
275
276Int_t AliHLTITSClusterFinderComponent::DoDeinit() {
277 // see header file for class documentation
278
279 if ( fRawReader )
280 delete fRawReader;
281 fRawReader = NULL;
282
6b7742a2 283 if ( fDettype )
284 delete fDettype;
285 fDettype = NULL;
286
287 if ( fgeomInit )
288 delete fgeomInit;
289 fgeomInit = NULL;
3f61e9ce 290
291 delete fSPD;
292 fSPD = 0;
6b7742a2 293
a2a2a7ce 294 delete fSSD;
295 fSSD = 0;
296
a2a2a7ce 297 fUseOfflineFinder = 0;
298
29d7dbc9 299 if (fpLoader) {
300 fpLoader->UnloadDigits();
301 }
302 fpLoader=NULL;
303
6b7742a2 304 return 0;
305}
306
a2a2a7ce 307int AliHLTITSClusterFinderComponent::DoEvent
308(
309 const AliHLTComponentEventData& evtData,
5ae74c42 310 const AliHLTComponentBlockData* /*blocks*/,
a2a2a7ce 311 AliHLTComponentTriggerData& /*trigData*/,
312 AliHLTUInt8_t* outputPtr,
313 AliHLTUInt32_t& size,
314 vector<AliHLTComponentBlockData>& outputBlocks )
315{
316 // see header file for class documentation
317
318 AliHLTUInt32_t maxBufferSize = size;
319 size = 0; // output size
6b7742a2 320
a2a2a7ce 321 if (!IsDataEvent()) return 0;
322
6b7742a2 323 if ( evtData.fBlockCnt<=0 )
a2a2a7ce 324 {
325 HLTDebug("no blocks in event" );
326 return 0;
327 }
57a4102f 328
29d7dbc9 329 AliHLTUInt32_t totalInputSize=0;
57a4102f 330 fBenchmark.StartNewEvent();
331 fBenchmark.Start(0);
332 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(fInputDataType); i!=NULL; i=GetNextInputBlock() ){
29d7dbc9 333 totalInputSize+=i->fSize;
57a4102f 334 fBenchmark.AddInput(i->fSize);
335 }
336
a2a2a7ce 337 Int_t ret = 0;
57a4102f 338
618f422f 339 if(fModeSwitch==kClusterFinderDigits) {
57a4102f 340
618f422f 341 for ( const TObject *iter = GetFirstInputObject(fInputDataType); iter != NULL; iter = GetNextInputObject() ) {
342 tD = dynamic_cast<TTree*>(const_cast<TObject*>( iter ) );
343 if(!tD){
344 HLTFatal("No Digit Tree found");
345 return -1;
346 }
9f2cda35 347 // 2010-04-17 very crude workaround: TTree objects are difficult to send
348 // The actual case: Running ITS and TPC reconstruction fails at the second event
349 // to read the ITS digits from the TreeD
350 //
351 // Reason: reading fails in TBranch::GetBasket, there a new basket is opened from
352 // a TFile object. The function TBranch::GetFile returns the file object from
353 // an internal fDirectory (TDirectory) object. This file is at the second event
354 // set to the TPC.Digits.root. The internal mismatch creates a seg fault
355 //
356 // Investigation: TBranch::Streamer uses a crude assignment after creating the
357 // TBranch object
358 // fDirectory = gDirectory;
359 // gDirectory is obviously not set correctly. Setting the directory to a TFile
360 // object for the ITS digits helps to fix the internal mess. Tried also to set
361 // the Directory for the TreeD to NULL (This has only effect if ones sets it
362 // to something not NULL first, and then to NULL). But then no content, i.e.
363 // ITS clusters could be retrieved.
364 //
365 // Conclusion: TTree objects are hardly to be sent via TMessage, there are direct
366 // links to the file required anyhow.
29d7dbc9 367 //
368 // 2011-01-28 hotfix reloaded: accessing the files like that fails if there are
369 // multiple digit files because of a large number of events. New ugly fix is to
370 // use the global runloader instance to get hold on the digits tree.
8e5edf3c 371 fnClusters = 0;
29d7dbc9 372 AliRunLoader* pRunLoader=AliRunLoader::Instance();
373 if (!pRunLoader) {
374 HLTError("failed to get global runloader instance");
375 return -ENOSYS;
376 }
377 // get the specific loader for the module
378 if (!fpLoader) {
379 const char* loaderType="ITSLoader";
380 fpLoader=pRunLoader->GetLoader(loaderType);
381 if (!fpLoader) {
382 HLTError("can not get loader \"%s\" from runloader", loaderType);
383 return -ENOSYS;
384 }
385 // prepare the loader
386 fpLoader->LoadDigits("read");
387 }
388 pRunLoader->GetEvent(GetEventCount());
389
390 tD=fpLoader->TreeD();
8e5edf3c 391 tR->Reset();
9f2cda35 392 tR->SetDirectory(0);
618f422f 393 fDettype->SetTreeAddressD(tD);
394 fDettype->MakeBranch(tR,"R");
395 fDettype->SetTreeAddressR(tR);
396 Option_t *opt="All";
57a4102f 397 fBenchmark.Start(1);
3384df26 398 fDettype->DigitsToRecPoints(tD,tR,0,opt,0);
57a4102f 399 fBenchmark.Stop(1);
9f2cda35 400 TClonesArray * fRecPoints = NULL;
618f422f 401 tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
402 for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
403 tR->GetEntry(treeEntry);
8e5edf3c 404 fnClusters += fRecPoints->GetEntries();
618f422f 405 }
9f2cda35 406
8e5edf3c 407 UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
618f422f 408 if( size + bufferSize > maxBufferSize ){
29d7dbc9 409 //HLTWarning( "Output buffer size exceed (buffer size %d, required size %d)", maxBufferSize, size+bufferSize);
410 if (totalInputSize>0) {
411 fInputMultiplierDigits=(float)(size+bufferSize)/totalInputSize;
412 fInputMultiplierDigits+=1.;
413 } else {
414 fOutputSizeOffset=totalInputSize;
415 fInputMultiplierDigits=1.;
416 }
618f422f 417 ret = -ENOSPC;
418 break;
419 }
8e5edf3c 420 if( fnClusters>0 ){
57a4102f 421 fBenchmark.Start(1);
618f422f 422 RecPointToSpacePoint(outputPtr,size);
57a4102f 423 fBenchmark.Stop(1);
618f422f 424 AliHLTComponentBlockData bd;
425 FillBlockData( bd );
426 bd.fOffset = size;
427 bd.fSize = bufferSize;
428 bd.fSpecification = 0x00000000;
429 bd.fDataType = GetOutputDataType();
430 outputBlocks.push_back( bd );
431 size += bufferSize;
57a4102f 432 fBenchmark.AddOutput(bd.fSize);
618f422f 433 }
434 }
435 }
436 else{
01ef1bd4 437
438 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
439
618f422f 440 // -- Loop over blocks
441 for( const AliHLTComponentBlockData* iter = GetFirstInputBlock(fInputDataType); iter != NULL; iter = GetNextInputBlock() ) {
8e5edf3c 442
443 if(fUseOfflineFinder){
444 if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();}
445 if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();}
446 }
447 if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();}
618f422f 448
449 // -- Debug output of datatype --
450 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
6b7742a2 451 evtData.fEventID, evtData.fEventID,
452 DataType2Text(iter->fDataType).c_str(),
df7307a2 453 DataType2Text(fInputDataType).c_str());
618f422f 454
455 // -- Check for the correct data type
456 if ( iter->fDataType != (fInputDataType) )
457 continue;
458
459 // -- Get equipment ID out of specification
460 AliHLTUInt32_t spec = iter->fSpecification;
461
462 Int_t id = fId;
463 for ( Int_t ii = 0; ii < fNddl ; ii++ ) { //number of ddl's
464 if ( spec & 0x00000001 ) {
465 id += ii;
466 break;
467 }
468 spec = spec >> 1 ;
6b7742a2 469 }
618f422f 470
471 // -- Set equipment ID to the raw reader
472
544538fb 473 if(!fRawReader){
474 HLTWarning("The fRawReader pointer is NULL");
475 continue;
476 }
477
618f422f 478 if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){
479 HLTWarning("Could not add buffer");
480 }
57a4102f 481
482 fBenchmark.Start(1);
483
8e5edf3c 484 fnClusters = 0;
485
618f422f 486 if(fModeSwitch==kClusterFinderSPD && !fUseOfflineFinder){ fSPD->RawdataToClusters( fRawReader, fclusters ); }
487 else if(fModeSwitch==kClusterFinderSSD && !fUseOfflineFinder){ fSSD->RawdataToClusters( fclusters ); }
488 else{
01ef1bd4 489 if(fModeSwitch==kClusterFinderSPD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SPD");}
490 if(fModeSwitch==kClusterFinderSSD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SSD");}
491 if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,"SDD");}
01ef1bd4 492 TClonesArray* clusters = NULL;
493 for(int i=fFirstModule;i<fLastModule;i++){
494 clusters = rpc->UncheckedGetClusters(i);
495 if(clusters != NULL){
8e5edf3c 496 fnClusters += clusters->GetEntriesFast();
3f61e9ce 497 }
618f422f 498 }
a2a2a7ce 499 }
8e5edf3c 500
501 /* Do not work
502 if(fModeSwitch==kClusterfinderSPD){
503 fnClusters = rpc->GetNClustersInLayerFast(1) + rpc->GetNClustersInLayerFast(2);
504 }
505 if(fModeSwitch==kClusterfinderSDD){
506 fnClusters = rpc->GetNClustersInLayerFast(3) + rpc->GetNClustersInLayerFast(4);
507 }
508 if(fModeSwitch==kClusterfinderSSD){
509 fnClusters = rpc->GetNClustersInLayerFast(5) + rpc->GetNClustersInLayerFast(6);
510 }
511 */
512
57a4102f 513 fBenchmark.Stop(1);
618f422f 514
515 fRawReader->ClearBuffers();
618f422f 516
8e5edf3c 517 UInt_t nClusters=fclusters.size();
518 if(nClusters>0){fnClusters = nClusters;}
519
520 UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
618f422f 521 if( size + bufferSize > maxBufferSize ){
522 HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize, size+bufferSize);
523 ret = -ENOSPC;
524 break;
525 }
8e5edf3c 526 if( fnClusters>0 ){
618f422f 527
528 RecPointToSpacePoint(outputPtr,size);
529
530 AliHLTComponentBlockData bd;
531 FillBlockData( bd );
532 bd.fOffset = size;
533 bd.fSize = bufferSize;
534 bd.fSpecification = iter->fSpecification;
535 bd.fDataType = GetOutputDataType();
536 outputBlocks.push_back( bd );
537 size += bufferSize;
57a4102f 538 fBenchmark.AddOutput(bd.fSize);
8e5edf3c 539 if(nClusters>0){fclusters.clear();}
618f422f 540 }
541
542 } // input blocks
543 }
3f61e9ce 544
57a4102f 545 fBenchmark.Stop(0);
546 HLTInfo(fBenchmark.GetStatistics());
a2a2a7ce 547 return ret;
6b7742a2 548}
549
550int AliHLTITSClusterFinderComponent::Configure(const char* arguments)
551{
552
553 int iResult=0;
554
555 if (!arguments) return iResult;
556
557 TString allArgs=arguments;
558 TString argument;
559
560 TObjArray* pTokens=allArgs.Tokenize(" ");
561
562 if (pTokens) {
563 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
564 argument=((TObjString*)pTokens->At(i))->GetString();
a2a2a7ce 565 if (argument.IsNull()) continue;
566 if (argument.CompareTo("-use-offline-finder")==0) {
567 fUseOfflineFinder = 1;
568 HLTInfo("Off-line ClusterFinder will be used");
6b7742a2 569 continue;
570 }
a2a2a7ce 571 /*
6b7742a2 572 else if (argument.CompareTo("")==0) {
573 HLTInfo("");
574 continue;
575 }
576 */
577 else {
578 HLTError("unknown argument %s", argument.Data());
579 iResult=-EINVAL;
580 break;
581 }
582 }
583 delete pTokens;
584 }
585
586 return iResult;
587}
588
589int AliHLTITSClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
590{
591 // see header file for class documentation
592 int iResult=0;
593
a3479b55 594 const char* path="";
595
596 switch(fModeSwitch){
597 case kClusterFinderSPD:
598 path = "HLT/ConfigITS/ITSClusterFinderSPD";
599 break;
600 case kClusterFinderSDD:
601 path = "HLT/ConfigITS/ITSClusterFinderSDD";
602 break;
603 case kClusterFinderSSD:
604 path = "HLT/ConfigITS/ITSClusterFinderSSD";
605 break;
606 case kClusterFinderDigits:
607 path = "";
608 break;
609 default:
610 HLTFatal("unknown cluster finder");
611 }
612
6b7742a2 613 const char* defaultNotify="";
614 if (cdbEntry) {
615 path=cdbEntry;
616 defaultNotify=" (default)";
617 }
618 if (path) {
619 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
620 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
621 if (pEntry) {
622 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
623 if (pString) {
624 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
625 iResult=Configure(pString->GetString().Data());
626 } else {
627 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
628 }
629 } else {
630 HLTError("can not fetch object \"%s\" from CDB", path);
631 }
632 }
633
634 return iResult;
635}
6eb9783a 636void AliHLTITSClusterFinderComponent::GetOCDBObjectDescription( TMap* const targetMap)
637{
638 // Get a list of OCDB object description.
639 if (!targetMap) return;
640 //SPD
641 targetMap->Add(new TObjString("ITS/Calib/SPDNoisy"),new TObjString("Calibration object for SPD" ));
642 targetMap->Add(new TObjString("ITS/Calib/SPDDead"),new TObjString("Calibration object for SPD" ));
643 targetMap->Add(new TObjString("TRIGGER/SPD/PITConditions"),new TObjString("Calibration object for SPD" ));
644 //SDD
645 targetMap->Add(new TObjString("ITS/Calib/CalibSDD"),new TObjString("Calibration object for SDD" ));
646 targetMap->Add(new TObjString("ITS/Calib/RespSDD"),new TObjString("Calibration object for SDD" ));
647 targetMap->Add(new TObjString("ITS/Calib/DriftSpeedSDD"),new TObjString("Calibration object for SDD" ));
648 targetMap->Add(new TObjString("ITS/Calib/DDLMapSDD"),new TObjString("Calibration object for SDD" ));
649 targetMap->Add(new TObjString("ITS/Calib/MapsTimeSDD"),new TObjString("Calibration object for SDD" ));
650 //SSD
651 targetMap->Add(new TObjString("ITS/Calib/NoiseSSD"),new TObjString("Calibration object for SSD" ));
652 targetMap->Add(new TObjString("ITS/Calib/GainSSD"),new TObjString("Calibration object for SSD" ));
653 targetMap->Add(new TObjString("ITS/Calib/BadChannelsSSD"),new TObjString("Calibration object for SSD" ));
654 //General reconstruction
655 targetMap->Add(new TObjString("GRP/CTP/Scalers"),new TObjString("General reconstruction object" ));
656}
657
658
618f422f 659void AliHLTITSClusterFinderComponent::RecPointToSpacePoint(AliHLTUInt8_t* outputPtr,AliHLTUInt32_t& size){
660 AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(outputPtr + size);
8e5edf3c 661 outputClusters->fSpacePointCnt=fnClusters;
618f422f 662 int clustIdx=0;
8e5edf3c 663 if(fModeSwitch==kClusterFinderDigits) {
664 TClonesArray * fRecPoints = NULL;
665 tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
666 for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
667 tR->GetEntry(treeEntry);
668 fnClusters += fRecPoints->GetEntries();
669 for(Int_t tCloneEntry=0;tCloneEntry<fRecPoints->GetEntries();tCloneEntry++){
670 AliITSRecPoint *recpoint=(AliITSRecPoint*)fRecPoints->At(tCloneEntry);
671 RecpointToOutput(outputClusters,recpoint,clustIdx);
672 }
673 }
674 }
675 else if(fclusters.size()>0){
676 for(UInt_t i=0;i<fclusters.size();i++){
677 AliITSRecPoint *recpoint = (AliITSRecPoint*) &(fclusters[i]);
678 RecpointToOutput(outputClusters,recpoint,clustIdx);
679 }
618f422f 680 }
8e5edf3c 681 else{
682 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
683 TClonesArray* clusters = NULL;
684 for(Int_t i=fFirstModule;i<fLastModule;i++){
685 clusters = rpc->UncheckedGetClusters(i);
686 for(Int_t j=0;j<clusters->GetEntriesFast();j++){
687 AliITSRecPoint *recpoint = (AliITSRecPoint*) clusters->At(j);
688 RecpointToOutput(outputClusters,recpoint,clustIdx);
689 }
690 }
691 }
692}
693
694void AliHLTITSClusterFinderComponent::RecpointToOutput(AliHLTITSClusterData *outputClusters, AliITSRecPoint *recpoint, int &clustIdx){
695 outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY();
696 outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ();
697 outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2();
698 outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2();
699 outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ();
700 outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ();
701 outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy();
702 outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz();
703 outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer();
704 outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex();
705 outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0);
706 outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1);
707 outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2);
708 clustIdx++;
618f422f 709}