]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCAgent.cxx
fix coverity warning
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCAgent.cxx
CommitLineData
51e9ec2a 1// $Id$
5578cf60 2
0efebbac 3//**************************************************************************
e26c6356 4//* This file is property of and copyright by the *
0efebbac 5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
0efebbac 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//**************************************************************************
5578cf60 17
51e9ec2a 18// @file AliHLTTPCAgent.cxx
19// @author Matthias Richter
20// @date
21// @brief Agent of the libAliHLTTPC library
22// @note
5578cf60 23
24#include "AliHLTTPCAgent.h"
626bfcc1 25#include "AliHLTTPCDefinitions.h"
26#include "AliHLTOUT.h"
73449074 27#include "AliHLTOUTHandlerChain.h"
86d5f217 28#include "AliHLTMisc.h"
352670bf 29#include "AliRunLoader.h"
286c9940 30#include "AliCDBManager.h"
31#include "AliCDBEntry.h"
32#include "AliTPCParam.h"
86d5f217 33#include "AliTPCRecoParam.h"
34#include "TObject.h"
5578cf60 35
36/** global instance for agent registration */
37AliHLTTPCAgent gAliHLTTPCAgent;
38
e1440dab 39// component headers
751d16ac 40#include "AliHLTTPCCAInputDataCompressorComponent.h"
400d857a 41#include "AliHLTTPCCATrackerComponent.h"
ae481371 42#include "AliHLTTPCCATrackerOutputConverter.h"
a6fb14f5 43#include "AliHLTTPCTrackMCMarkerComponent.h"
400d857a 44#include "AliHLTTPCCAGlobalMergerComponent.h"
0973c527 45#include "AliHLTTPCdEdxComponent.h"
f43cfd4a 46#include "AliHLTTPCdEdxMonitoringComponent.h"
672f8b8c 47#include "AliHLTTPCClusterFinderComponent.h"
672f8b8c 48#include "AliHLTTPCDigitPublisherComponent.h"
e1440dab 49#include "AliHLTTPCDigitDumpComponent.h"
0efebbac 50#include "AliHLTTPCClusterDumpComponent.h"
0efebbac 51#include "AliHLTTPCClusterHistoComponent.h"
3a3550fa 52#include "AliHLTTPCHistogramHandlerComponent.h"
22f34176 53#include "AliHLTTPCTrackHistoComponent.h"
54#include "AliHLTTPCTrackDumpComponent.h"
a912b63b 55#include "AliHLTTPCHWCFDataReverterComponent.h"
6af4f584 56#include "AliHLTTPCHWClusterTransformComponent.h"
cfe8311c 57#include "AliHLTTPCCFComparisonComponent.h"
098c0d28 58#include "AliHLTTPCDataCheckerComponent.h"
c012881c 59#include "AliHLTTPCHWCFEmulatorComponent.h"
60#include "AliHLTTPCHWCFConsistencyControlComponent.h"
9703a636 61#include "AliHLTTPCDataCompressionComponent.h"
cad2fa68 62#include "AliHLTTPCDataCompressionMonitorComponent.h"
86d5f217 63#include "AliHLTTPCDataCompressionFilterComponent.h"
62a19eee 64#include "AliHLTTPCDataPublisherComponent.h"
49bdc466 65#include "AliHLTTPCHWClusterDecoderComponent.h"
66#include "AliHLTTPCClusterTransformationComponent.h"
e1440dab 67
5578cf60 68/** ROOT macro for the implementation of ROOT specific class methods */
69ClassImp(AliHLTTPCAgent)
70
71AliHLTTPCAgent::AliHLTTPCAgent()
51e9ec2a 72 : AliHLTModuleAgent("TPC")
73 , fRawDataHandler(NULL)
74 , fTracksegsDataHandler(NULL)
75 , fClustersDataHandler(NULL)
994a608f 76 , fCompressionMonitorHandler(NULL)
5578cf60 77{
78 // see header file for class documentation
79 // or
80 // refer to README to build package
81 // or
82 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
83}
84
85AliHLTTPCAgent::~AliHLTTPCAgent()
86{
87 // see header file for class documentation
88}
89
90int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
4fc08fff 91 AliRawReader* rawReader,
7c6a3cd3 92 AliRunLoader* runloader) const
5578cf60 93{
94 // see header file for class documentation
95 if (handler) {
62a19eee 96 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
97 // AliReconstruction: indicated by runloader==NULL, run always on raw data
98 bool bPublishRaw=rawReader!=NULL || runloader==NULL;
672f8b8c 99
100 // This the tracking configuration for the full TPC
101 // - 216 clusterfinders (1 per partition)
102 // - 36 slice trackers
103 // - one global merger
104 // - the esd converter
105 // The ESD is shipped embedded into a TTree
dfa1592e 106 int iMinSlice=0;
672f8b8c 107 int iMaxSlice=35;
dfa1592e 108 int iMinPart=0;
672f8b8c 109 int iMaxPart=5;
6d7c2d25 110 TString arg;
672f8b8c 111 TString mergerInput;
cad2fa68 112 TString sinkRawData;
4dd739b4 113 TString sinkHWClusterInput;
5090799b 114 TString dEdXInput;
62a19eee 115 TString hwclustOutput;
9703a636 116 TString compressorInput;
62a19eee 117 TString trackerInput;
118
119
e26c6356 120 arg.Form("-publish-raw filtered");
62a19eee 121 handler->CreateConfiguration("TPC-DP", "TPCDataPublisher", NULL , arg.Data());
122
dfa1592e 123 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
dfa1592e 124 for (int part=iMinPart; part<=iMaxPart; part++) {
62a19eee 125 TString publisher;
dfa1592e 126
127 // digit publisher components
0ba35c53 128 publisher.Form("TPC-DP_%02d_%d", slice, part);
62a19eee 129 if (bPublishRaw) {
7c6a3cd3 130 // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
62a19eee 131 // AliReconstruction: indicated by runloader==NULL, run always on raw data
4fc08fff 132 int ddlno=768;
133 if (part>1) ddlno+=72+4*slice+(part-2);
134 else ddlno+=2*slice+part;
e26c6356 135 arg.Form("-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x", slice, slice, part, part);
136 handler->CreateConfiguration(publisher.Data(), "BlockFilter", "TPC-DP" , arg.Data());
62a19eee 137 if (sinkRawData.Length()>0) sinkRawData+=" ";
138 sinkRawData+=publisher;
7c6a3cd3 139 } else {
140 arg.Form("-slice %d -partition %d", slice, part);
141 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
4fc08fff 142 }
dfa1592e 143
4dd739b4 144 // Hardware CF emulator
4dd739b4 145 TString hwcfemu;
146 hwcfemu.Form("TPC-HWCFEmu_%02d_%d", slice, part);
62a19eee 147 arg="";
148 if (!bPublishRaw) arg+=" -do-mc 1";
149 handler->CreateConfiguration(hwcfemu.Data(), "TPCHWClusterFinderEmulator", publisher.Data(), arg.Data());
150 if (hwclustOutput.Length()>0) hwclustOutput+=" ";
151 hwclustOutput+=hwcfemu;
49bdc466 152
4dd739b4 153 TString hwcf;
154 hwcf.Form("TPC-HWCF_%02d_%d", slice, part);
29a4c9f5 155 handler->CreateConfiguration(hwcf.Data(), "TPCHWClusterTransform",hwcfemu.Data(), "-publish-raw");
4dd739b4 156
49bdc466 157 //if (trackerInput.Length()>0) trackerInput+=" ";
158 //trackerInput+=hwcf;
159 //if (dEdXInput.Length()>0) dEdXInput+=" ";
160 //dEdXInput+=hwcf;
161 //if (sinkHWClusterInput.Length()>0) sinkHWClusterInput+=" ";
162 //sinkHWClusterInput+=hwcf;
dfa1592e 163 }
62a19eee 164 }
49bdc466 165
166 TString hwcfDecoder = "TPC-HWCFDecoder";
167 handler->CreateConfiguration(hwcfDecoder.Data(), "TPCHWClusterDecoder",hwclustOutput.Data(), "");
168
169 TString clusterTransformation = "TPC-ClusterTransformation";
170 handler->CreateConfiguration(clusterTransformation.Data(), "TPCClusterTransformation",hwcfDecoder.Data(), "");
171
172 if (trackerInput.Length()>0) trackerInput+=" ";
173 trackerInput+=clusterTransformation;
174 if (dEdXInput.Length()>0) dEdXInput+=" ";
175 dEdXInput+=clusterTransformation;
176 if (sinkHWClusterInput.Length()>0) sinkHWClusterInput+=" ";
177 sinkHWClusterInput+=clusterTransformation;
dfa1592e 178
62a19eee 179 // tracker finder component
180 // 2012-01-05 changing the configuration according to online setup
181 // the tracking strategy has been changed in the online system in Sep 2011
182 // the tracker now processes all clusters, and several of this 'global' trackers
183 // run in parallel. The GlobalMerger is still in the chain as it produces the final
184 // fit.
185 TString tracker;
186 tracker.Form("TPC-TR");
187 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "-GlobalTracking");
dfa1592e 188
62a19eee 189 if (mergerInput.Length()>0) mergerInput+=" ";
190 mergerInput+=tracker;
5578cf60 191
672f8b8c 192 // GlobalMerger component
fc7c0369 193 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
672f8b8c 194
9703a636 195 // dEdx component
5090799b 196 if (dEdXInput.Length()>0) dEdXInput+=" ";
197 dEdXInput+="TPC-globalmerger";
198
199 handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
200
9703a636 201 // compression component
202 if (compressorInput.Length()>0) compressorInput+=" ";
49bdc466 203 //compressorInput+=hwclustOutput;
204 compressorInput+=hwcfDecoder;
9703a636 205
86d5f217 206 // special configuration to run the emulation automatically if the compressed clusters
207 // of a particular partition is missing. This configuration is announced for reconstruction
208 // of raw data if the HLT mode of the TPC reconstruction is enabled. Compression component
209 // always needs to run in mode 1. Even if the recorded data is mode 3 (optimized partition
210 // clusters), 2 (track model compression), or 4. The emulation can not be in mode 2 or 4,
211 // since the track model block can not be identified with a partition. Have to duplicate the
212 // configuration of the compression component
e26c6356 213 handler->CreateConfiguration("TPC-compression-emulation", "TPCDataCompressor", compressorInput.Data(), "-mode 1");
214
215 if (compressorInput.Length()>0) compressorInput+=" ";
216 compressorInput+="TPC-globalmerger";
217 handler->CreateConfiguration("TPC-compression", "TPCDataCompressor", compressorInput.Data(), "");
218 handler->CreateConfiguration("TPC-compression-huffman-trainer", "TPCDataCompressor", compressorInput.Data(),"-deflater-mode 3");
219 handler->CreateConfiguration("TPC-compression-monitoring-component", "TPCDataCompressorMonitor", "TPC-compression TPC-hwcfdata","-pushback-period=30");
220 handler->CreateConfiguration("TPC-compression-monitoring", "ROOTFileWriter", "TPC-compression-monitoring-component","-concatenate-events -overwrite -datafile HLT.TPCDataCompression-statistics.root");
86d5f217 221
672f8b8c 222 // the esd converter configuration
791fbeb7 223 TString converterInput="TPC-globalmerger";
62a19eee 224 if (!bPublishRaw) {
791fbeb7 225 // propagate cluster info to the esd converter in order to fill the MC information
8ee277c5 226 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
6595fdc6 227 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
791fbeb7 228 converterInput+=" ";
6595fdc6 229 converterInput+="TPC-mcTrackMarker";
791fbeb7 230 }
231 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
73449074 232
84bb5f35 233 // cluster dump collection
62a19eee 234 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
235 handler->CreateConfiguration("TPC-raw-clusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
4dd739b4 236 handler->CreateConfiguration("TPC-hwclusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
237 handler->CreateConfiguration("TPC-raw-hwclusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
84bb5f35 238
cad2fa68 239 // raw data
240 handler->CreateConfiguration("TPC-raw-data", "BlockFilter" , sinkRawData.Data(), "");
241
62a19eee 242 handler->CreateConfiguration("TPC-hwcfdata", "BlockFilter" , hwclustOutput.Data(), "-datatype 'HWCLUST1' 'TPC '");
cad2fa68 243
6d7c2d25 244 /////////////////////////////////////////////////////////////////////////////////////
245 //
246 // dumps on the ALTRO digit level
247 //
248 // selected channel dump
249 arg.Form("-datafile selected-channel.dump -specfmt=_0x%%08x -subdir -blcknofmt= -idfmt=");
250 handler->CreateConfiguration("TPC-selected-altro-digits", "TPCDigitDump", "RCU-channelselect", arg.Data());
251
252 // raw channel dump
253 arg.Form("-datafile channel.dump -specfmt=_0x%%08x -subdir -blcknofmt= -idfmt=");
254 handler->CreateConfiguration("TPC-raw-altro-digits", "TPCDigitDump", "TPC-raw-data", arg.Data());
255
73449074 256 /////////////////////////////////////////////////////////////////////////////////////
257 //
258 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
259 // collects the data blocks, merges the tracks and produces an ESD object
260
261 // publisher component
262 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
263
264 // GlobalMerger component
265 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
266
267 // the esd converter configuration
268 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
269
270 /////////////////////////////////////////////////////////////////////////////////////
271 //
272 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
273 // produces an ESD object from the track structure
274
275 // publisher component
276 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
277
278 // the esd converter configuration
279 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
51e9ec2a 280
281 /////////////////////////////////////////////////////////////////////////////////////
282 //
283 // a kChain HLTOUT configuration for processing of {'CLUSTERS':'TPC '} data blocks
284 // stores the blocks in file HLT.TPC.Clusters.root in HOMER format
285
286 // publisher component
287 handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher" , NULL, "");
288
289 // the HLTOUT component collects the blocks and stores the file
290 handler->CreateConfiguration("TPC-hltout-cluster-dump", "HLTOUT", "TPC-hltout-cluster-publisher", "-digitfile HLT.TPC.Clusters.root -rawout=off -links 2");
d3bfee20 291
292 /////////////////////////////////////////////////////////////////////////////////////
293 //
294 // monitoring of compressed TPC data {CLUSTRAW:TPC }, {REMCLSCM,TPC }, {CLSTRKCM,TPC }
295 //
296
297 // publisher component
298 handler->CreateConfiguration("TPC-hltout-compressionmonitor-publisher", "AliHLTOUTPublisher" , NULL,
994a608f 299 "-datatype HWCLUST1 'TPC ' "
300 "-datatype CLUSTRAW 'TPC ' "
301 "-datatype REMCLSCM 'TPC ' "
302 "-datatype CLSTRKCM 'TPC ' "
303 "-datatype REMCLIDS 'TPC ' "
304 "-datatype CLIDSTRK 'TPC ' "
d3bfee20 305 );
306
307 // the HLTOUT component collects the blocks and stores the file
de8cc8f8 308 handler->CreateConfiguration("TPC-hltout-compressionmonitor", "TPCDataCompressorMonitor", "TPC-hltout-compressionmonitor-publisher", "-histogram-file HLT.TPC-compression-statistics.root -publishing-mode off");
5578cf60 309 }
51e9ec2a 310
5578cf60 311 return 0;
312}
313
dee38f1b 314const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
ff6648de 315 AliRunLoader* runloader) const
5578cf60 316{
317 // see header file for class documentation
ff6648de 318 if (runloader) {
319 // reconstruction chains for AliRoot simulation
62a19eee 320 return "TPC-compression";
86d5f217 321 } else {
982fe123 322 return "TPC-compression-emulation";
ff6648de 323 }
324 return NULL;
5578cf60 325}
326
327const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
328{
329 // see header file for class documentation
5ad1e184 330
331 // actually, the TPC library has dependencies to Util and RCU
332 // so the two has to be loaded anyhow before we get here
333 //return "libAliHLTUtil.so libAliHLTRCU.so";
9c790772 334 return "libAliHLTUtil.so";
5578cf60 335}
f3506ea2 336
e1440dab 337int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
f3506ea2 338{
e1440dab 339 // see header file for class documentation
340 if (!pHandler) return -EINVAL;
672f8b8c 341
751d16ac 342 pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
400d857a 343 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
ae481371 344 pHandler->AddComponent(new AliHLTTPCCATrackerOutputConverter);
400d857a 345 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
a6fb14f5 346 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
0973c527 347 pHandler->AddComponent(new AliHLTTPCdEdxComponent);
f43cfd4a 348 pHandler->AddComponent(new AliHLTTPCdEdxMonitoringComponent);
672f8b8c 349 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
350 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
351 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
6f23f6cc 352 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
672f8b8c 353 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
e1440dab 354 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
0efebbac 355 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
0efebbac 356 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
3a3550fa 357 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
22f34176 358 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
359 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
a912b63b 360 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
6af4f584 361 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
cfe8311c 362 pHandler->AddComponent(new AliHLTTPCCFComparisonComponent);
098c0d28 363 pHandler->AddComponent(new AliHLTTPCDataCheckerComponent);
c012881c 364 pHandler->AddComponent(new AliHLTTPCHWCFEmulatorComponent);
f42d2ad3 365// pHandler->AddComponent(new AliHLTTPCHWCFConsistencyControlComponent); //FIXME: Causes crash: https://savannah.cern.ch/bugs/?83677
9703a636 366 pHandler->AddComponent(new AliHLTTPCDataCompressionComponent);
cad2fa68 367 pHandler->AddComponent(new AliHLTTPCDataCompressionMonitorComponent);
86d5f217 368 pHandler->AddComponent(new AliHLTTPCDataCompressionFilterComponent);
62a19eee 369 pHandler->AddComponent(new AliHLTTPCDataPublisherComponent);
49bdc466 370 pHandler->AddComponent(new AliHLTTPCHWClusterDecoderComponent);
371 pHandler->AddComponent(new AliHLTTPCClusterTransformationComponent);
f3506ea2 372 return 0;
373}
626bfcc1 374
375int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
376 AliHLTUInt32_t spec,
377 AliHLTOUTHandlerDesc& desc) const
378{
379 // see header file for class documentation
73449074 380
381 // raw data blocks to be fed into offline reconstruction
626bfcc1 382 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
383 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
384 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
385 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
386 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
387 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
388 return 1;
389 } else {
390 HLTWarning("handler can not process merged data from multiple ddls:"
391 " min slice %d, max slice %d, min part %d, max part %d",
392 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
393 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
394 return 0;
395 }
396 }
73449074 397
51e9ec2a 398 // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
84bb5f35 399 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
51e9ec2a 400 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
84bb5f35 401 return 1;
402 }
403
994a608f 404 // define handlers for all blocks related to compression, flag if the
405 // cluster id blocks are existing, this will be used to decide
406 // whether to create the handler or not
f2834ee5 407 // {'CLUSTRAW':'TPC '}
994a608f 408 // {'HWCLUST1':'TPC '}
f2834ee5 409 // {'REMCLSCM':'TPC '}
410 // {'CLSTRKCM':'TPC '}
52c3443e 411 // {'REMCLIDS':'TPC '}
412 // {'CLIDSTRK':'TPC '}
413 if (dt==AliHLTTPCDefinitions::RawClustersDataType() ||
994a608f 414 dt==AliHLTTPCDefinitions::HWClustersDataType() ||
f2834ee5 415 dt==AliHLTTPCDefinitions::RemainingClustersCompressedDataType() ||
994a608f 416 dt==AliHLTTPCDefinitions::ClusterTracksCompressedDataType()) {
417 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
418 return 1;
419 }
420 if (dt==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
52c3443e 421 dt==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
5e75f4e0 422 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
994a608f 423 const_cast<AliHLTTPCAgent*>(this)->SetBit(kHaveCompressedClusterIdDataBlock);
5e75f4e0 424 return 1;
425 }
426
427 // {'CLMCINFO':'TPC '}
428 if (dt==AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo) {
429 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
430 return 1;
431 }
432
73449074 433 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
434 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
435 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
436 return 1;
437 }
438
439 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
440 // there is only one data block
441 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
442 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
443 return 1;
444 }
626bfcc1 445 return 0;
446}
447
448AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
b0914d2e 449 AliHLTUInt32_t /*spec*/)
626bfcc1 450{
451 // see header file for class documentation
73449074 452
453 // raw data blocks to be fed into offline reconstruction
626bfcc1 454 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
455 if (!fRawDataHandler) {
456 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
457 }
626bfcc1 458 return fRawDataHandler;
459 }
73449074 460
51e9ec2a 461 // dump for {'CLUSTERS':'TPC '}, stored in a file HLT.TPC.Clusters.root in HOMER format
462 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
463 if (fClustersDataHandler==NULL)
464 fClustersDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-cluster-dump libHLTsim.so libAliHLTUtil.so");
465 return fClustersDataHandler;
466 }
467
73449074 468 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
469 // in a kChain HLTOUT handler
470 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
471 if (fTracksegsDataHandler==NULL)
472 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
473 return fTracksegsDataHandler;
474 }
475
476 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
477 // there is only one data block
478 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
479 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
480 }
481
994a608f 482 // monitoring of compressed data if cluster verification blocks exist
483 // {'REMCLIDS':'TPC '}
484 // {'CLIDSTRK':'TPC '}
485 // FIXME: needs to be commissioned
486 // if (dt==AliHLTTPCDefinitions::RawClustersDataType() ||
487 // dt==AliHLTTPCDefinitions::HWClustersDataType() ||
488 // dt==AliHLTTPCDefinitions::RemainingClustersCompressedDataType() ||
489 // dt==AliHLTTPCDefinitions::ClusterTracksCompressedDataType() ||
490 // dt==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
491 // dt==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
492 // const char* arg="chains=TPC-hltout-compressionmonitor";
493 // if (!TestBit(kHaveCompressedClusterIdDataBlock))
494 // arg="chains=TPC-hltout-compressionmonitorpublisher";
495 // if (!fCompressionMonitorHandler)
496 // fCompressionMonitorHandler=new AliHLTOUTHandlerChain(arg);
497 // return fCompressionMonitorHandler;
498 // }
499
626bfcc1 500 return NULL;
501}
502
503int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
504{
505 // see header file for class documentation
506 if (pInstance==NULL) return -EINVAL;
507
508 if (pInstance==fRawDataHandler) {
73449074 509 delete fRawDataHandler;
510 fRawDataHandler=NULL;
511 }
512
513 if (pInstance==fTracksegsDataHandler) {
514 delete fTracksegsDataHandler;
515 fTracksegsDataHandler=NULL;
626bfcc1 516 }
51e9ec2a 517
518 if (pInstance==fClustersDataHandler) {
519 delete fClustersDataHandler;
520 fClustersDataHandler=NULL;
521 }
522
994a608f 523 if (pInstance==fCompressionMonitorHandler) {
524 delete fCompressionMonitorHandler;
525 fCompressionMonitorHandler=NULL;
526 }
527
626bfcc1 528 return 0;
529}
530
531AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
532{
533 // see header file for class documentation
534}
535
536AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
537{
538 // see header file for class documentation
539}
540
541int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
542{
543 // see header file for class documentation
544 if (!pData) return -EINVAL;
545 AliHLTComponentDataType dt=kAliHLTVoidDataType;
546 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
547 int iResult=pData->GetDataBlockDescription(dt, spec);
548 if (iResult>=0) {
549 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
550 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
551 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
552 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
553 iResult=768;
554 if (part>1) iResult+=72+4*slice+(part-2);
555 else iResult+=2*slice+part;
556 } else {
557 HLTError("handler can not process merged data from multiple ddls:"
558 " min slice %d, max slice %d, min part %d, max part %d",
559 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
560 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
561 iResult=-EBADMSG;
562 }
563 }
564 return iResult;
565}