]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TRD/AliHLTTRDClusterizerComponent.cxx
Bugfixes in the Calo physics histo component
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDClusterizerComponent.cxx
CommitLineData
0af7cb2e 1// $Id$
2
4de61263 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: *
8//* for The ALICE HLT 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//**************************************************************************
0af7cb2e 18
19/** @file AliHLTTRDClusterizerComponent.cxx
4de61263 20 @author
0af7cb2e 21 @date
4de61263 22 @brief A TRDClusterizer processing component for the HLT.
23*/
0af7cb2e 24
c7500dae 25// see header file for class documentation //
26// or //
27// refer to README to build package //
28// or //
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt //
30
0af7cb2e 31#if __GNUC__ >= 3
32using namespace std;
33#endif
34
051a0e2d 35#include "TTree.h"
36#include "TFile.h"
37#include "TBranch.h"
38
0af7cb2e 39#include "AliHLTTRDClusterizerComponent.h"
40#include "AliHLTTRDDefinitions.h"
e47650f5 41#include "AliHLTTRDClusterizer.h"
0af7cb2e 42
886e8d3d 43#include "AliGeomManager.h"
44#include "AliTRDReconstructor.h"
0af7cb2e 45#include "AliCDBManager.h"
775f67d7 46#include "AliCDBStorage.h"
b32b76cb 47#include "AliCDBEntry.h"
519f385f 48#include "AliTRDrecoParam.h"
49#include "AliTRDrawStreamBase.h"
d679dd6c 50#include "AliTRDcluster.h"
519f385f 51
0af7cb2e 52#include "AliRawReaderMemory.h"
53
d679dd6c 54#ifdef HAVE_VALGRIND_CALLGRIND_H
55#include <valgrind/callgrind.h>
56#else
e3e5ac39 57#define CALLGRIND_START_INSTRUMENTATION do { } while (0)
58#define CALLGRIND_STOP_INSTRUMENTATION do { } while (0)
d679dd6c 59#endif
60
0af7cb2e 61#include <cstdlib>
62#include <cerrno>
63#include <string>
64
93ce7d1b 65#include "AliTRDrawStream.h"
66#include "AliTRDrawFastStream.h"
67
18ada816 68ClassImp(AliHLTTRDClusterizerComponent)
3b021c25 69
93ce7d1b 70AliHLTTRDClusterizerComponent::AliHLTTRDClusterizerComponent()
71: AliHLTProcessor(),
775f67d7 72 fOutputPercentage(500),
73 fOutputConst(0),
d679dd6c 74 fClusterizer(NULL),
75 fRecoParam(NULL),
d679dd6c 76 fMemReader(NULL),
b32b76cb 77 fReconstructor(NULL),
78 fRecoParamType(-1),
79 fRecoDataType(-1),
80 fRawDataVersion(2),
81 fyPosMethod(1),
82 fgeometryFileName(""),
83 fProcessTracklets(kFALSE),
a8277796 84 fHLTstreamer(kTRUE),
2359a6ef 85 fTC(kFALSE),
e47650f5 86 fHLTflag(kTRUE),
87 fHighLevelOutput(kFALSE),
88 fEmulateHLTClusters(kFALSE)
0af7cb2e 89{
3b021c25 90 // Default constructor
051a0e2d 91
0af7cb2e 92}
93
94AliHLTTRDClusterizerComponent::~AliHLTTRDClusterizerComponent()
95{
3b021c25 96 // Destructor
886e8d3d 97 // Work is Done in DoDeInit()
0af7cb2e 98}
d679dd6c 99
d679dd6c 100
0af7cb2e 101const char* AliHLTTRDClusterizerComponent::GetComponentID()
102{
3b021c25 103 // Return the component ID const char *
0af7cb2e 104 return "TRDClusterizer"; // The ID of this component
105}
106
107void AliHLTTRDClusterizerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
108{
3b021c25 109 // Get the list of input data
0af7cb2e 110 list.clear(); // We do not have any requirements for our input data type(s).
93ce7d1b 111 list.push_back(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD);
0af7cb2e 112}
113
93ce7d1b 114AliHLTComponentDataType AliHLTTRDClusterizerComponent::GetOutputDataType()
0af7cb2e 115{
3b021c25 116 // Get the output data type
775f67d7 117 return kAliHLTMultipleDataType;
0af7cb2e 118}
119
775f67d7 120int AliHLTTRDClusterizerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
121{
122 // Get the output data type
123 tgtList.clear();
124 tgtList.push_back(AliHLTTRDDefinitions::fgkClusterDataType);
125 tgtList.push_back(AliHLTTRDDefinitions::fgkMCMtrackletDataType);
126 return tgtList.size();
127}
128
129
0af7cb2e 130void AliHLTTRDClusterizerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
131{
3b021c25 132 // Get the output data size
775f67d7 133 constBase = fOutputConst;
0af7cb2e 134 inputMultiplier = ((double)fOutputPercentage)/100.0;
135}
136
0af7cb2e 137AliHLTComponent* AliHLTTRDClusterizerComponent::Spawn()
138{
3b021c25 139 // Spawn function, return new instance of this class
0af7cb2e 140 return new AliHLTTRDClusterizerComponent;
141};
142
143int AliHLTTRDClusterizerComponent::DoInit( int argc, const char** argv )
144{
145 // perform initialization. We check whether our relative output size is specified in the arguments.
b32b76cb 146 int iResult=0;
519f385f 147
0d66dbf5 148 fReconstructor = new AliTRDReconstructor();
b32b76cb 149 HLTDebug("TRDReconstructor at 0x%x", fReconstructor);
150
151 TString configuration="";
152 TString argument="";
153 for (int i=0; i<argc && iResult>=0; i++) {
154 argument=argv[i];
155 if (!configuration.IsNull()) configuration+=" ";
156 configuration+=argument;
e3e5ac39 157 }
775f67d7 158
b32b76cb 159 if (!configuration.IsNull()) {
160 iResult=Configure(configuration.Data());
161 } else {
162 iResult=Reconfigure(NULL, NULL);
163 }
519f385f 164
b32b76cb 165 if(!fClusterizer){
166 HLTFatal("Clusterizer was not initialized!");
775f67d7 167 return -1;
168 }
051a0e2d 169
4de61263 170 if(iResult<0) return iResult;
171
b32b76cb 172 fMemReader = new AliRawReaderMemory;
9aea5deb 173 fClusterizer->SetReconstructor(fReconstructor);
56397b53 174 fClusterizer->SetUseLabels(kFALSE);
775f67d7 175
176 if(fReconstructor->IsProcessingTracklets())
177 fOutputConst = fClusterizer->GetTrMemBlockSize();
93ce7d1b 178
4de61263 179 return iResult;
0af7cb2e 180}
181
182int AliHLTTRDClusterizerComponent::DoDeinit()
183{
3b021c25 184 // Deinitialization of the component
185 delete fMemReader;
186 fMemReader = 0;
187 delete fClusterizer;
188 fClusterizer = 0;
9aea5deb 189
190 fReconstructor->SetClusters(0x0);
0d66dbf5 191 delete fReconstructor;
192 fReconstructor = 0x0;
0af7cb2e 193 return 0;
194
519f385f 195 if (fRecoParam)
196 {
197 HLTDebug("Deleting fRecoParam");
198 delete fRecoParam;
199 fRecoParam = 0;
200 }
0af7cb2e 201}
202
886e8d3d 203int AliHLTTRDClusterizerComponent::DoEvent( const AliHLTComponentEventData& evtData,
204 const AliHLTComponentBlockData* blocks,
205 AliHLTComponent_TriggerData& /*trigData*/,
d679dd6c 206 AliHLTUInt8_t* outputPtr,
a28bfa0d 207 AliHLTUInt32_t& size,
d679dd6c 208 vector<AliHLTComponent_BlockData>& outputBlocks )
0af7cb2e 209{
3b021c25 210 // Process an event
775f67d7 211
212 if (evtData.fEventID == 1)
213 CALLGRIND_START_INSTRUMENTATION;
214
215 HLTDebug( "NofBlocks %i", evtData.fBlockCnt );
0af7cb2e 216 // Process an event
d679dd6c 217 AliHLTUInt32_t totalSize = 0, offset = 0;
0af7cb2e 218
051a0e2d 219 //implement a usage of the following
519f385f 220 // AliHLTUInt32_t triggerDataStructSize = trigData.fStructSize;
221 // AliHLTUInt32_t triggerDataSize = trigData.fDataSize;
222 // void *triggerData = trigData.fData;
886e8d3d 223 //HLTDebug( "Trigger data received. Struct size %d Data size %d Data location 0x%x", trigData.fStructSize, trigData.fDataSize, (UInt_t*)trigData.fData);
051a0e2d 224
0af7cb2e 225 // Loop over all input blocks in the event
886e8d3d 226 AliHLTComponentDataType expectedDataType = (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD);
775f67d7 227 for ( UInt_t iBlock = 0; iBlock < evtData.fBlockCnt; iBlock++ )
228 {
229 const AliHLTComponentBlockData &block = blocks[iBlock];
519f385f 230 // lets not use the internal TRD data types here : AliHLTTRDDefinitions::fgkDDLRawDataType
231 // which is depreciated - we use HLT global defs instead
d679dd6c 232 // if ( block.fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTRD) )
233 AliHLTComponentDataType inputDataType = block.fDataType;
886e8d3d 234 if ( inputDataType != expectedDataType)
0af7cb2e 235 {
775f67d7 236 HLTDebug( "Block # %i/%i; Event 0x%08LX (%Lu) Wrong received datatype: %s - required datatype: %s; Skipping",
237 iBlock, evtData.fBlockCnt,
9aea5deb 238 evtData.fEventID, evtData.fEventID,
239 DataType2Text(inputDataType).c_str(),
240 DataType2Text(expectedDataType).c_str());
e47650f5 241 if(block.fDataType == kAliHLTDataTypeEOR)
242 CALLGRIND_STOP_INSTRUMENTATION;
0af7cb2e 243 continue;
244 }
9aea5deb 245 else
246 {
775f67d7 247 HLTDebug("We get the right data type: Block # %i/%i; Event 0x%08LX (%Lu) Received datatype: %s; Block Size: %i",
248 iBlock, evtData.fBlockCnt,
249 evtData.fEventID, evtData.fEventID,
250 DataType2Text(inputDataType).c_str(),
251 block.fSize);
9aea5deb 252 }
253
4de61263 254#ifndef NDEBUG
255 unsigned long constBase;
256 double inputMultiplier;
257 GetOutputDataSize(constBase,inputMultiplier);
258 if(size<(constBase+block.fSize*inputMultiplier)){
259 HLTWarning("Memory Block given might be too small: %i < %i; Event %Lu", size, constBase+block.fSize*inputMultiplier, evtData.fEventID);
260 }
261#endif
262
263 // fMemReader->Reset();
d679dd6c 264 fMemReader->SetMemory((UChar_t*) block.fPtr, block.fSize);
886e8d3d 265
d679dd6c 266 AliHLTUInt32_t spec = block.fSpecification;
886e8d3d 267
268 Int_t id = 1024;
269
b3182b67 270 for ( Int_t ii = 0; ii < 18 ; ii++ ) {
b32b76cb 271 if ( spec & 0x1 ) {
886e8d3d 272 id += ii;
273 break;
274 }
275 spec = spec >> 1 ;
276 }
886e8d3d 277
d679dd6c 278 fMemReader->SetEquipmentID( id );
279
775f67d7 280 fClusterizer->SetMemBlock(outputPtr+offset);
93ce7d1b 281 Bool_t bclustered = fClusterizer->Raw2ClustersChamber(fMemReader);
282 if(bclustered)
0af7cb2e 283 {
93ce7d1b 284 HLTDebug("Clustered successfully");
886e8d3d 285 }
286 else
287 {
288 HLTError("Clustering ERROR");
0af7cb2e 289 return -1;
290 }
519f385f 291
775f67d7 292 AliHLTUInt32_t addedSize;
293 if(fReconstructor->IsProcessingTracklets()){
294 addedSize = fClusterizer->GetAddedTrSize();
295 totalSize += fClusterizer->GetTrMemBlockSize(); //if IsProcessingTracklets() is enabled we always reserve a data block of size GetTrMemBlockSize() for the tracklets
dc2e6604 296 if (addedSize > 0){
297 // Using low-level interface
298 // with interface classes
dc2e6604 299 if ( totalSize > size )
0134491a 300 {
dc2e6604 301 HLTError("Too much data; Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
302 totalSize, size );
303 return EMSGSIZE;
0134491a 304 }
775f67d7 305
dc2e6604 306 // Fill block
307 AliHLTComponentBlockData bd;
308 FillBlockData( bd );
309 bd.fOffset = offset;
310 bd.fSize = addedSize;
ff350753 311 bd.fSpecification = block.fSpecification;
775f67d7 312 bd.fDataType = AliHLTTRDDefinitions::fgkMCMtrackletDataType;
dc2e6604 313 outputBlocks.push_back( bd );
93ce7d1b 314 HLTDebug( "BD ptr 0x%x, offset %i, size %i, dataType %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), spec);
0134491a 315 }
775f67d7 316 offset = totalSize;
317 }
318
319 addedSize = fClusterizer->GetAddedClSize();
320 if (addedSize > 0){
93ce7d1b 321
322 Int_t* nTimeBins = (Int_t*)(outputPtr+offset+fClusterizer->GetAddedClSize());
323 *nTimeBins = fClusterizer->GetNTimeBins();
324 addedSize += sizeof(*nTimeBins);
325
775f67d7 326 totalSize += addedSize;
327 if ( totalSize > size )
328 {
329 HLTError("Too much data; Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
330 totalSize, size );
331 return EMSGSIZE;
332 }
93ce7d1b 333
775f67d7 334 // Fill block
335 AliHLTComponentBlockData bd;
336 FillBlockData( bd );
337 bd.fOffset = offset;
338 bd.fSize = addedSize;
ff350753 339 bd.fSpecification = block.fSpecification;
775f67d7 340 bd.fDataType = AliHLTTRDDefinitions::fgkClusterDataType;
341 outputBlocks.push_back( bd );
93ce7d1b 342 HLTDebug( "BD ptr 0x%x, offset %i, size %i, dataType %s, spec 0x%x ", bd.fPtr, bd.fOffset, bd.fSize, DataType2Text(bd.fDataType).c_str(), spec);
775f67d7 343 offset = totalSize;
775f67d7 344 }
e03c1166 345 else{
060f29ad 346 HLTDebug("Array of clusters is empty!");
e03c1166 347 }
dc2e6604 348 }
d679dd6c 349 fReconstructor->SetClusters(0x0);
b39f18ce 350
d679dd6c 351 size = totalSize;
352 HLTDebug("Event is done. size written to the output is %i", size);
353 return 0;
354}
355
d679dd6c 356void AliHLTTRDClusterizerComponent::PrintObject( TClonesArray* inClustersArray)
357{
358 AliTRDcluster* cluster=0x0;
9aea5deb 359
d679dd6c 360 for (Int_t i=0; i < inClustersArray->GetEntriesFast(); i++){
361 cluster = dynamic_cast<AliTRDcluster*>(inClustersArray->At(i));
362 HLTDebug("cluster[%i]",i);
363 HLTDebug(" PadCol = %i; PadRow = %i; PadTime = %i", cluster->GetPadCol(), cluster->GetPadRow(), cluster->GetPadTime());
364 HLTDebug(" Detector = %i, Amplitude = %f, Center = %f", cluster->GetDetector(), cluster->GetQ(), cluster->GetCenter());
365 HLTDebug(" LocalTimeBin = %i; NPads = %i; maskedPosition: %s, status: %s", cluster->GetLocalTimeBin(), cluster->GetNPads(),cluster->GetPadMaskedPosition(),cluster->GetPadMaskedPosition());
366 }
9aea5deb 367
0af7cb2e 368}
b32b76cb 369
370int AliHLTTRDClusterizerComponent::Configure(const char* arguments){
371 int iResult=0;
372 if (!arguments) return iResult;
373
374 TString allArgs=arguments;
375 TString argument;
376 int bMissingParam=0;
377
378 TObjArray* pTokens=allArgs.Tokenize(" ");
379 if (pTokens) {
380 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
381 argument=((TObjString*)pTokens->At(i))->GetString();
382 if (argument.IsNull()) continue;
383
4de61263 384 if (argument.CompareTo("output_percentage")==0) {
b32b76cb 385 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
386 HLTInfo("Setting output percentage to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
387 fOutputPercentage=((TObjString*)pTokens->At(i))->GetString().Atoi();
388 continue;
389 }
390 else if (argument.CompareTo("-geometry")==0) {
391 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
392 HLTInfo("Setting geometry to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
393 fgeometryFileName=((TObjString*)pTokens->At(i))->GetString();
394 continue;
395 }
93ce7d1b 396 else if (argument.CompareTo("-lowflux")==0) {
b32b76cb 397 fRecoParamType = 0;
398 HLTInfo("Low flux reconstruction selected");
399 continue;
400 }
93ce7d1b 401 else if (argument.CompareTo("-highflux")==0) {
b32b76cb 402 fRecoParamType = 1;
403 HLTInfo("High flux reconstruction selected");
404 continue;
405 }
93ce7d1b 406 else if (argument.CompareTo("-cosmics")==0) {
b32b76cb 407 fRecoParamType = 2;
408 HLTInfo("Cosmics reconstruction selected");
409 continue;
410 }
93ce7d1b 411 else if (argument.CompareTo("-simulation")==0) {
b32b76cb 412 fRecoDataType = 0;
413 HLTInfo("Awaiting simulated data");
414 continue;
415 }
93ce7d1b 416 else if (argument.CompareTo("-experiment")==0) {
b32b76cb 417 fRecoDataType = 1;
418 HLTInfo("Awaiting real data");
419 continue;
420 }
93ce7d1b 421 else if (argument.CompareTo("-processTracklets")==0) {
b32b76cb 422 fProcessTracklets = kTRUE;
93ce7d1b 423 HLTInfo("Writing L1 tracklets to output");
b32b76cb 424 continue;
425 }
93ce7d1b 426 else if (argument.CompareTo("-noZS")==0) {
b32b76cb 427 fOutputPercentage = 100;
428 HLTInfo("Awaiting non zero surpressed data");
429 continue;
430 }
e47650f5 431 else if (argument.CompareTo("-HLTflag")==0) {
432 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
433 TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
434 if (toCompareTo.CompareTo("yes")==0){
435 HLTInfo("Setting HLTflag to: %s", toCompareTo.Data());
436 fHLTflag=kTRUE;
437 }
438 else if (toCompareTo.CompareTo("no")==0){
439 HLTInfo("Setting HLTflag to: %s", toCompareTo.Data());
440 fHLTflag=kFALSE;
441 }
442 else {
443 HLTError("unknown argument for HLTflag: %s", toCompareTo.Data());
444 iResult=-EINVAL;
445 break;
446 }
447 continue;
448 }
93ce7d1b 449 else if (argument.CompareTo("-faststreamer")==0) {
b32b76cb 450 fHLTstreamer = kTRUE;
451 HLTInfo("Useing fast raw streamer");
452 continue;
453 }
93ce7d1b 454 else if (argument.CompareTo("-nofaststreamer")==0) {
455 fHLTstreamer = kFALSE;
456 HLTInfo("Don't use fast raw streamer");
457 continue;
458 }
a8277796 459 else if (argument.CompareTo("-tailcancellation")==0) {
460 fTC = kTRUE;
461 HLTInfo("Useing tailcancellation");
462 continue;
463 }
b32b76cb 464 else if (argument.CompareTo("-rawver")==0) {
465 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
466 HLTInfo("Raw data version is: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
467 fRawDataVersion=((TObjString*)pTokens->At(i))->GetString().Atoi();
468 continue;
469 }
e47650f5 470 else if (argument.CompareTo("-highLevelOutput")==0) {
471 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
472 TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
473 if (toCompareTo.CompareTo("yes")==0){
474 HLTWarning("Setting highLevelOutput to: %s", toCompareTo.Data());
475 fHighLevelOutput=kTRUE;
476 }
477 else if (toCompareTo.CompareTo("no")==0){
478 HLTInfo("Setting highLevelOutput to: %s", toCompareTo.Data());
479 fHighLevelOutput=kFALSE;
480 }
481 else {
482 HLTError("unknown argument for highLevelOutput: %s", toCompareTo.Data());
483 iResult=-EINVAL;
484 break;
485 }
486 continue;
487 }
488 else if (argument.CompareTo("-emulateHLTClusters")==0) {
489 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
490 TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
491 if (toCompareTo.CompareTo("yes")==0){
492 HLTWarning("Setting emulateHLTTracks to: %s", toCompareTo.Data());
493 fEmulateHLTClusters=kTRUE;
494 }
495 else if (toCompareTo.CompareTo("no")==0){
496 HLTInfo("Setting emulateHLTTracks to: %s", toCompareTo.Data());
497 fEmulateHLTClusters=kFALSE;
498 }
499 else {
500 HLTError("unknown argument for emulateHLTTracks: %s", toCompareTo.Data());
501 iResult=-EINVAL;
502 break;
503 }
504 continue;
505 }
b32b76cb 506 else if (argument.CompareTo("-yPosMethod")==0) {
507 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
508 TString toCompareTo=((TObjString*)pTokens->At(i))->GetString();
509 if (toCompareTo.CompareTo("COG")==0){
510 HLTInfo("Setting yPosMethod method to: %s", toCompareTo.Data());
511 fyPosMethod=0;
512 }
513 else if (toCompareTo.CompareTo("LUT")==0){
514 HLTInfo("Setting yPosMethod method to: %s", toCompareTo.Data());
515 fyPosMethod=1;
516 }
517 else if (toCompareTo.CompareTo("Gauss")==0){
518 HLTInfo("Setting yPosMethod method to: %s", toCompareTo.Data());
519 fyPosMethod=2;
520 }
521 else {
522 HLTError("unknown argument for yPosMethod: %s", toCompareTo.Data());
523 iResult=-EINVAL;
524 break;
525 }
526 continue;
93ce7d1b 527 }
b32b76cb 528
529 else {
530 HLTError("unknown argument: %s", argument.Data());
531 iResult=-EINVAL;
532 break;
533 }
534 }
535 delete pTokens;
536 }
537 if (bMissingParam) {
538 HLTError("missing parameter for argument %s", argument.Data());
539 iResult=-EINVAL;
540 }
541 if(iResult>=0){
b32b76cb 542 iResult=SetParams();
543 }
544 return iResult;
545}
546
547int AliHLTTRDClusterizerComponent::SetParams()
548{
549 Int_t iResult=0;
550 if(!AliCDBManager::Instance()->IsDefaultStorageSet()){
4de61263 551 HLTError("DefaultStorage is not set in CDBManager");
b32b76cb 552 return -EINVAL;
553 }
554 if(AliCDBManager::Instance()->GetRun()<0){
555 HLTError("Run Number is not set in CDBManager");
556 return -EINVAL;
557 }
558 HLTInfo("CDB default storage: %s; RunNo: %i", (AliCDBManager::Instance()->GetDefaultStorage()->GetBaseFolder()).Data(), AliCDBManager::Instance()->GetRun());
559
560 if(!AliGeomManager::GetGeometry()){
1eedaf94 561 if(fgeometryFileName.CompareTo("")==0 || !TFile::Open(fgeometryFileName.Data())){
b32b76cb 562 HLTInfo("Loading standard geometry file");
563 AliGeomManager::LoadGeometry();
564 }else{
565 HLTWarning("Loading NON-standard geometry file");
566 AliGeomManager::LoadGeometry(fgeometryFileName.Data());
567 }
568 if(!AliGeomManager::GetGeometry()){
4de61263 569 HLTError("Could not load geometry");
b32b76cb 570 return -EINVAL;
571 }
ba9a8c85 572 HLTInfo("Applying Alignment from CDB object");
573 AliGeomManager::ApplyAlignObjsFromCDB("TRD");
b32b76cb 574 }
575 else{
576 HLTInfo("Geometry Already Loaded!");
577 }
578
e47650f5 579 if(fReconstructor->GetRecoParam()){
580 fRecoParam = new AliTRDrecoParam(*fReconstructor->GetRecoParam());
581 HLTInfo("RecoParam already set!");
582 }else{
583 if(fRecoParamType == 0){
b32b76cb 584 HLTDebug("Low flux params init.");
585 fRecoParam = AliTRDrecoParam::GetLowFluxParam();
586 }
e47650f5 587 if(fRecoParamType == 1){
b32b76cb 588 HLTDebug("High flux params init.");
589 fRecoParam = AliTRDrecoParam::GetHighFluxParam();
590 }
e47650f5 591 if(fRecoParamType == 2){
b32b76cb 592 HLTDebug("Cosmic Test params init.");
593 fRecoParam = AliTRDrecoParam::GetCosmicTestParam();
594 }
e47650f5 595 }
b32b76cb 596
e47650f5 597 if (!fRecoParam)
b32b76cb 598 {
599 HLTError("No reco params initialized. Sniffing big trouble!");
600 return -EINVAL;
601 }
602
2fc8c061 603 // backward compatibility to AliTRDrecoParam < r34995
604# ifndef HAVE_NOT_ALITRDRECOPARAM_r34995
605# define AliTRDRecoParamSetTailCancelation(b) fRecoParam->SetTailCancelation(b)
606# define AliTRDRecoParamSetGAUS(b) fRecoParam->SetGAUS(b)
607# define AliTRDRecoParamSetLUT(b) fRecoParam->SetLUT(b)
608# else
609# define AliTRDRecoParamSetTailCancelation(b) fRecoParam->SetTailCancelation()
610# define AliTRDRecoParamSetGAUS(b) fRecoParam->SetGAUS()
611# define AliTRDRecoParamSetLUT(b) fRecoParam->SetLUT()
612# endif
613
e47650f5 614 if(fTC){fRecoParam->SetTailCancelation(kTRUE); HLTDebug("Enableing Tail Cancelation"); }
615 else{fRecoParam->SetTailCancelation(kFALSE); HLTDebug("Disableing Tail Cancelation"); }
a8277796 616
9cafabed 617 switch(fyPosMethod){
2fc8c061 618 case 0: AliTRDRecoParamSetGAUS(kFALSE); AliTRDRecoParamSetLUT(kFALSE); break;
619 case 1: AliTRDRecoParamSetGAUS(kFALSE); AliTRDRecoParamSetLUT(kTRUE); break;
620 case 2: AliTRDRecoParamSetGAUS(kTRUE); AliTRDRecoParamSetLUT(kFALSE); break;
9cafabed 621 }
622
a2fbb6ec 623 fRecoParam->SetStreamLevel(AliTRDrecoParam::kClusterizer, 0);
b32b76cb 624 fReconstructor->SetRecoParam(fRecoParam);
b32b76cb 625
e47650f5 626 TString recoOptions="!cw";
627 if(fHLTflag)
628 recoOptions += ",hlt";
9cafabed 629 if(fProcessTracklets) recoOptions += ",tp";
630 else recoOptions += ",!tp";
631
b32b76cb 632 HLTDebug("Reconstructor options are: %s",recoOptions.Data());
633 fReconstructor->SetOption(recoOptions.Data());
634
635 if (fRecoDataType < 0 || fRecoDataType > 1)
636 {
637 HLTWarning("No data type selected. Use -simulation or -experiment flag. Defaulting to simulation.");
638 fRecoDataType = 0;
639 }
640
641 if (fRecoDataType == 0)
642 {
643 AliTRDrawStreamBase::SetRawStreamVersion(AliTRDrawStreamBase::kTRDsimStream);
644 HLTDebug("Data type expected is SIMULATION!");
645 }
646
647 if (fRecoDataType == 1)
648 {
649 AliTRDrawStreamBase::SetRawStreamVersion(AliTRDrawStreamBase::kTRDrealStream);
650 HLTDebug("Data type expected is EXPERIMENT!");
651 }
652
653 if (fHLTstreamer)
654 {
655 AliTRDrawStreamBase::SetRawStreamVersion("FAST");
656 HLTDebug("fast rawstreamer used");
657 }
658
659 if(!fClusterizer){
660 fClusterizer = new AliHLTTRDClusterizer("TRDCclusterizer", "TRDCclusterizer");
661 HLTDebug("TRDClusterizer at 0x%x", fClusterizer);
662 }
663
664 fClusterizer->SetRawVersion(fRawDataVersion);
665
666 return iResult;
667}
668
b32b76cb 669int AliHLTTRDClusterizerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
670{
671 // see header file for class documentation
672
673 int iResult=0;
674 const char* path="HLT/ConfigTRD/ClusterizerComponent";
675 const char* defaultNotify="";
676 if (cdbEntry) {
677 path=cdbEntry;
678 defaultNotify=" (default)";
679 }
680 if (path) {
681 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
682 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
683 if (pEntry) {
684 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
685 if (pString) {
686 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
687 iResult=Configure(pString->GetString().Data());
688 } else {
689 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
690 }
691 } else {
692 HLTError("cannot fetch object \"%s\" from CDB", path);
693 }
694 }
695
696 return iResult;
697}