]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCAgent.cxx
code cleanup, removing unused functionality; fully implemented in the AliHLTTPCDataCo...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCAgent.cxx
CommitLineData
51e9ec2a 1// $Id$
5578cf60 2
0efebbac 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: Matthias Richter <Matthias.Richter@ift.uib.no> *
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//**************************************************************************
5578cf60 18
51e9ec2a 19// @file AliHLTTPCAgent.cxx
20// @author Matthias Richter
21// @date
22// @brief Agent of the libAliHLTTPC library
23// @note
5578cf60 24
25#include "AliHLTTPCAgent.h"
626bfcc1 26#include "AliHLTTPCDefinitions.h"
27#include "AliHLTOUT.h"
73449074 28#include "AliHLTOUTHandlerChain.h"
86d5f217 29#include "AliHLTMisc.h"
352670bf 30#include "AliRunLoader.h"
286c9940 31#include "AliCDBManager.h"
32#include "AliCDBEntry.h"
33#include "AliTPCParam.h"
86d5f217 34#include "AliTPCRecoParam.h"
35#include "TObject.h"
5578cf60 36
37/** global instance for agent registration */
38AliHLTTPCAgent gAliHLTTPCAgent;
39
e1440dab 40// component headers
751d16ac 41#include "AliHLTTPCCAInputDataCompressorComponent.h"
400d857a 42#include "AliHLTTPCCATrackerComponent.h"
ae481371 43#include "AliHLTTPCCATrackerOutputConverter.h"
a6fb14f5 44#include "AliHLTTPCTrackMCMarkerComponent.h"
400d857a 45#include "AliHLTTPCCAGlobalMergerComponent.h"
0973c527 46#include "AliHLTTPCdEdxComponent.h"
f43cfd4a 47#include "AliHLTTPCdEdxMonitoringComponent.h"
672f8b8c 48#include "AliHLTTPCClusterFinderComponent.h"
49#include "AliHLTTPCRawDataUnpackerComponent.h"
50#include "AliHLTTPCDigitPublisherComponent.h"
e1440dab 51#include "AliHLTTPCDigitDumpComponent.h"
0efebbac 52#include "AliHLTTPCClusterDumpComponent.h"
0efebbac 53#include "AliHLTTPCClusterHistoComponent.h"
3a3550fa 54#include "AliHLTTPCHistogramHandlerComponent.h"
22f34176 55#include "AliHLTTPCTrackHistoComponent.h"
56#include "AliHLTTPCTrackDumpComponent.h"
a912b63b 57#include "AliHLTTPCHWCFDataReverterComponent.h"
6af4f584 58#include "AliHLTTPCHWClusterTransformComponent.h"
cfe8311c 59#include "AliHLTTPCCFComparisonComponent.h"
098c0d28 60#include "AliHLTTPCDataCheckerComponent.h"
c012881c 61#include "AliHLTTPCHWCFEmulatorComponent.h"
62#include "AliHLTTPCHWCFConsistencyControlComponent.h"
9703a636 63#include "AliHLTTPCDataCompressionComponent.h"
cad2fa68 64#include "AliHLTTPCDataCompressionMonitorComponent.h"
86d5f217 65#include "AliHLTTPCDataCompressionFilterComponent.h"
62a19eee 66#include "AliHLTTPCDataPublisherComponent.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
120 arg.Form("-verbose");
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;
135 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
136 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , 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;
9703a636 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
dfa1592e 157 if (trackerInput.Length()>0) trackerInput+=" ";
4a1d41f3 158 trackerInput+=hwcf;
5090799b 159 if (dEdXInput.Length()>0) dEdXInput+=" ";
4a1d41f3 160 dEdXInput+=hwcf;
4dd739b4 161 if (sinkHWClusterInput.Length()>0) sinkHWClusterInput+=" ";
162 sinkHWClusterInput+=hwcf;
dfa1592e 163 }
62a19eee 164 }
dfa1592e 165
62a19eee 166 // tracker finder component
167 // 2012-01-05 changing the configuration according to online setup
168 // the tracking strategy has been changed in the online system in Sep 2011
169 // the tracker now processes all clusters, and several of this 'global' trackers
170 // run in parallel. The GlobalMerger is still in the chain as it produces the final
171 // fit.
172 TString tracker;
173 tracker.Form("TPC-TR");
174 handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "-GlobalTracking");
dfa1592e 175
62a19eee 176 if (mergerInput.Length()>0) mergerInput+=" ";
177 mergerInput+=tracker;
5578cf60 178
672f8b8c 179 // GlobalMerger component
fc7c0369 180 handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
672f8b8c 181
9703a636 182 // dEdx component
5090799b 183 if (dEdXInput.Length()>0) dEdXInput+=" ";
184 dEdXInput+="TPC-globalmerger";
185
186 handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
187
9703a636 188 // compression component
189 if (compressorInput.Length()>0) compressorInput+=" ";
62a19eee 190 compressorInput+=hwclustOutput;
191 if (compressorInput.Length()>0) compressorInput+=" ";
9703a636 192 compressorInput+="TPC-globalmerger";
39312d27 193 handler->CreateConfiguration("TPC-compression", "TPCDataCompressor", compressorInput.Data(), "");
1355cfef 194 handler->CreateConfiguration("TPC-compression-huffman-trainer", "TPCDataCompressor", compressorInput.Data(),"-deflater-mode 3");
39312d27 195 handler->CreateConfiguration("TPC-compression-monitoring-component", "TPCDataCompressorMonitor", "TPC-compression TPC-hwcfdata","-pushback-period=30");
196 handler->CreateConfiguration("TPC-compression-monitoring", "ROOTFileWriter", "TPC-compression-monitoring-component","-concatenate-events -overwrite -datafile HLT.TPCDataCompression-statistics.root");
9703a636 197
86d5f217 198 // special configuration to run the emulation automatically if the compressed clusters
199 // of a particular partition is missing. This configuration is announced for reconstruction
200 // of raw data if the HLT mode of the TPC reconstruction is enabled. Compression component
201 // always needs to run in mode 1. Even if the recorded data is mode 3 (optimized partition
202 // clusters), 2 (track model compression), or 4. The emulation can not be in mode 2 or 4,
203 // since the track model block can not be identified with a partition. Have to duplicate the
204 // configuration of the compression component
205 handler->CreateConfiguration("TPC-auto-compression-component", "TPCDataCompressor", compressorInput.Data(), "-mode 1");
206 handler->CreateConfiguration("TPC-auto-compression", "TPCDataCompressorFilter", "TPC-auto-compression-component","");
207
672f8b8c 208 // the esd converter configuration
791fbeb7 209 TString converterInput="TPC-globalmerger";
62a19eee 210 if (!bPublishRaw) {
791fbeb7 211 // propagate cluster info to the esd converter in order to fill the MC information
8ee277c5 212 handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");
6595fdc6 213 handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
791fbeb7 214 converterInput+=" ";
6595fdc6 215 converterInput+="TPC-mcTrackMarker";
791fbeb7 216 }
217 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , converterInput.Data(), "");
73449074 218
84bb5f35 219 // cluster dump collection
62a19eee 220 handler->CreateConfiguration("TPC-clusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
221 handler->CreateConfiguration("TPC-raw-clusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
4dd739b4 222 handler->CreateConfiguration("TPC-hwclusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
223 handler->CreateConfiguration("TPC-raw-hwclusters", "BlockFilter" , sinkHWClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
84bb5f35 224
cad2fa68 225 // raw data
226 handler->CreateConfiguration("TPC-raw-data", "BlockFilter" , sinkRawData.Data(), "");
227
62a19eee 228 handler->CreateConfiguration("TPC-hwcfdata", "BlockFilter" , hwclustOutput.Data(), "-datatype 'HWCLUST1' 'TPC '");
cad2fa68 229
6d7c2d25 230 /////////////////////////////////////////////////////////////////////////////////////
231 //
232 // dumps on the ALTRO digit level
233 //
234 // selected channel dump
235 arg.Form("-datafile selected-channel.dump -specfmt=_0x%%08x -subdir -blcknofmt= -idfmt=");
236 handler->CreateConfiguration("TPC-selected-altro-digits", "TPCDigitDump", "RCU-channelselect", arg.Data());
237
238 // raw channel dump
239 arg.Form("-datafile channel.dump -specfmt=_0x%%08x -subdir -blcknofmt= -idfmt=");
240 handler->CreateConfiguration("TPC-raw-altro-digits", "TPCDigitDump", "TPC-raw-data", arg.Data());
241
73449074 242 /////////////////////////////////////////////////////////////////////////////////////
243 //
244 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
245 // collects the data blocks, merges the tracks and produces an ESD object
246
247 // publisher component
248 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
249
250 // GlobalMerger component
251 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
252
253 // the esd converter configuration
254 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
255
256 /////////////////////////////////////////////////////////////////////////////////////
257 //
258 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
259 // produces an ESD object from the track structure
260
261 // publisher component
262 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
263
264 // the esd converter configuration
265 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
51e9ec2a 266
267 /////////////////////////////////////////////////////////////////////////////////////
268 //
269 // a kChain HLTOUT configuration for processing of {'CLUSTERS':'TPC '} data blocks
270 // stores the blocks in file HLT.TPC.Clusters.root in HOMER format
271
272 // publisher component
273 handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher" , NULL, "");
274
275 // the HLTOUT component collects the blocks and stores the file
276 handler->CreateConfiguration("TPC-hltout-cluster-dump", "HLTOUT", "TPC-hltout-cluster-publisher", "-digitfile HLT.TPC.Clusters.root -rawout=off -links 2");
d3bfee20 277
278 /////////////////////////////////////////////////////////////////////////////////////
279 //
280 // monitoring of compressed TPC data {CLUSTRAW:TPC }, {REMCLSCM,TPC }, {CLSTRKCM,TPC }
281 //
282
283 // publisher component
284 handler->CreateConfiguration("TPC-hltout-compressionmonitor-publisher", "AliHLTOUTPublisher" , NULL,
994a608f 285 "-datatype HWCLUST1 'TPC ' "
286 "-datatype CLUSTRAW 'TPC ' "
287 "-datatype REMCLSCM 'TPC ' "
288 "-datatype CLSTRKCM 'TPC ' "
289 "-datatype REMCLIDS 'TPC ' "
290 "-datatype CLIDSTRK 'TPC ' "
d3bfee20 291 );
292
293 // the HLTOUT component collects the blocks and stores the file
de8cc8f8 294 handler->CreateConfiguration("TPC-hltout-compressionmonitor", "TPCDataCompressorMonitor", "TPC-hltout-compressionmonitor-publisher", "-histogram-file HLT.TPC-compression-statistics.root -publishing-mode off");
5578cf60 295 }
51e9ec2a 296
5578cf60 297 return 0;
298}
299
dee38f1b 300const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
ff6648de 301 AliRunLoader* runloader) const
5578cf60 302{
303 // see header file for class documentation
ff6648de 304 if (runloader) {
305 // reconstruction chains for AliRoot simulation
62a19eee 306 return "TPC-compression";
86d5f217 307 } else {
308 bool bAddEmulation=true; // add by default
309
310 // FIXME:
311 // tried to make the configuration optional depending on whether the
312 // TPC requires HLT clusters or not, bu the RecoParam OCDB object is a TObjArray
313 // and the event specie is not yet defined. Maybe it can be derived from
314 // the GRP. On the other hand, HLT data compression is expected to be the
315 // default mode from now on, so this block might be safely deleted after some
316 // time (today is 2011-11-18)
317 //
318 // AliTPCRecoParam* param=NULL;
319 // TObject* pObject=AliHLTMisc::Instance().ExtractObject(AliHLTMisc::Instance().LoadOCDBEntry("TPC/Calib/RecoParam"));
320 // if (pObject && (param=dynamic_cast<AliTPCRecoParam*>(pObject))!=NULL) {
321 // bAddEmulation=param->GetUseHLTClusters()==3 || param->GetUseHLTClusters()==4;
322 // HLTInfo("%s auto-compression for not existing TPC partitions, TPCRecoParam::GetUseHLTClusters %d",
323 // bAddEmulation?"adding":"skipping",
324 // param->GetUseHLTClusters());
325 // }
326 if (bAddEmulation) {
327 // 2011-11-23: not yet enabled
328 // testing required, furthermore a component publishing only the raw data for
329 // the missing links, to big impact to performance otherwise
330 //return "TPC-auto-compression";
331 }
ff6648de 332 }
333 return NULL;
5578cf60 334}
335
336const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
337{
338 // see header file for class documentation
5ad1e184 339
340 // actually, the TPC library has dependencies to Util and RCU
341 // so the two has to be loaded anyhow before we get here
342 //return "libAliHLTUtil.so libAliHLTRCU.so";
9c790772 343 return "libAliHLTUtil.so";
5578cf60 344}
f3506ea2 345
e1440dab 346int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
f3506ea2 347{
e1440dab 348 // see header file for class documentation
349 if (!pHandler) return -EINVAL;
672f8b8c 350
751d16ac 351 pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
400d857a 352 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
ae481371 353 pHandler->AddComponent(new AliHLTTPCCATrackerOutputConverter);
400d857a 354 pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
a6fb14f5 355 pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
0973c527 356 pHandler->AddComponent(new AliHLTTPCdEdxComponent);
f43cfd4a 357 pHandler->AddComponent(new AliHLTTPCdEdxMonitoringComponent);
672f8b8c 358 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
359 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
360 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
6f23f6cc 361 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinder32Bit));
672f8b8c 362 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
363 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
e1440dab 364 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
0efebbac 365 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
0efebbac 366 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
3a3550fa 367 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
22f34176 368 pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
369 pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
a912b63b 370 pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
6af4f584 371 pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
cfe8311c 372 pHandler->AddComponent(new AliHLTTPCCFComparisonComponent);
098c0d28 373 pHandler->AddComponent(new AliHLTTPCDataCheckerComponent);
c012881c 374 pHandler->AddComponent(new AliHLTTPCHWCFEmulatorComponent);
f42d2ad3 375// pHandler->AddComponent(new AliHLTTPCHWCFConsistencyControlComponent); //FIXME: Causes crash: https://savannah.cern.ch/bugs/?83677
9703a636 376 pHandler->AddComponent(new AliHLTTPCDataCompressionComponent);
cad2fa68 377 pHandler->AddComponent(new AliHLTTPCDataCompressionMonitorComponent);
86d5f217 378 pHandler->AddComponent(new AliHLTTPCDataCompressionFilterComponent);
62a19eee 379 pHandler->AddComponent(new AliHLTTPCDataPublisherComponent);
f3506ea2 380 return 0;
381}
626bfcc1 382
383int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
384 AliHLTUInt32_t spec,
385 AliHLTOUTHandlerDesc& desc) const
386{
387 // see header file for class documentation
73449074 388
389 // raw data blocks to be fed into offline reconstruction
626bfcc1 390 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
391 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
392 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
393 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
394 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
395 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
396 return 1;
397 } else {
398 HLTWarning("handler can not process merged data from multiple ddls:"
399 " min slice %d, max slice %d, min part %d, max part %d",
400 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
401 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
402 return 0;
403 }
404 }
73449074 405
51e9ec2a 406 // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
84bb5f35 407 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
51e9ec2a 408 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
84bb5f35 409 return 1;
410 }
411
994a608f 412 // define handlers for all blocks related to compression, flag if the
413 // cluster id blocks are existing, this will be used to decide
414 // whether to create the handler or not
f2834ee5 415 // {'CLUSTRAW':'TPC '}
994a608f 416 // {'HWCLUST1':'TPC '}
f2834ee5 417 // {'REMCLSCM':'TPC '}
418 // {'CLSTRKCM':'TPC '}
52c3443e 419 // {'REMCLIDS':'TPC '}
420 // {'CLIDSTRK':'TPC '}
421 if (dt==AliHLTTPCDefinitions::RawClustersDataType() ||
994a608f 422 dt==AliHLTTPCDefinitions::HWClustersDataType() ||
f2834ee5 423 dt==AliHLTTPCDefinitions::RemainingClustersCompressedDataType() ||
994a608f 424 dt==AliHLTTPCDefinitions::ClusterTracksCompressedDataType()) {
425 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
426 return 1;
427 }
428 if (dt==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
52c3443e 429 dt==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
5e75f4e0 430 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
994a608f 431 const_cast<AliHLTTPCAgent*>(this)->SetBit(kHaveCompressedClusterIdDataBlock);
5e75f4e0 432 return 1;
433 }
434
435 // {'CLMCINFO':'TPC '}
436 if (dt==AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo) {
437 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
438 return 1;
439 }
440
73449074 441 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
442 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
443 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
444 return 1;
445 }
446
447 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
448 // there is only one data block
449 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
450 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
451 return 1;
452 }
626bfcc1 453 return 0;
454}
455
456AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
b0914d2e 457 AliHLTUInt32_t /*spec*/)
626bfcc1 458{
459 // see header file for class documentation
73449074 460
461 // raw data blocks to be fed into offline reconstruction
626bfcc1 462 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
463 if (!fRawDataHandler) {
464 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
465 }
626bfcc1 466 return fRawDataHandler;
467 }
73449074 468
51e9ec2a 469 // dump for {'CLUSTERS':'TPC '}, stored in a file HLT.TPC.Clusters.root in HOMER format
470 if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
471 if (fClustersDataHandler==NULL)
472 fClustersDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-cluster-dump libHLTsim.so libAliHLTUtil.so");
473 return fClustersDataHandler;
474 }
475
73449074 476 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
477 // in a kChain HLTOUT handler
478 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
479 if (fTracksegsDataHandler==NULL)
480 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
481 return fTracksegsDataHandler;
482 }
483
484 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
485 // there is only one data block
486 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
487 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
488 }
489
994a608f 490 // monitoring of compressed data if cluster verification blocks exist
491 // {'REMCLIDS':'TPC '}
492 // {'CLIDSTRK':'TPC '}
493 // FIXME: needs to be commissioned
494 // if (dt==AliHLTTPCDefinitions::RawClustersDataType() ||
495 // dt==AliHLTTPCDefinitions::HWClustersDataType() ||
496 // dt==AliHLTTPCDefinitions::RemainingClustersCompressedDataType() ||
497 // dt==AliHLTTPCDefinitions::ClusterTracksCompressedDataType() ||
498 // dt==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
499 // dt==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
500 // const char* arg="chains=TPC-hltout-compressionmonitor";
501 // if (!TestBit(kHaveCompressedClusterIdDataBlock))
502 // arg="chains=TPC-hltout-compressionmonitorpublisher";
503 // if (!fCompressionMonitorHandler)
504 // fCompressionMonitorHandler=new AliHLTOUTHandlerChain(arg);
505 // return fCompressionMonitorHandler;
506 // }
507
626bfcc1 508 return NULL;
509}
510
511int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
512{
513 // see header file for class documentation
514 if (pInstance==NULL) return -EINVAL;
515
516 if (pInstance==fRawDataHandler) {
73449074 517 delete fRawDataHandler;
518 fRawDataHandler=NULL;
519 }
520
521 if (pInstance==fTracksegsDataHandler) {
522 delete fTracksegsDataHandler;
523 fTracksegsDataHandler=NULL;
626bfcc1 524 }
51e9ec2a 525
526 if (pInstance==fClustersDataHandler) {
527 delete fClustersDataHandler;
528 fClustersDataHandler=NULL;
529 }
530
994a608f 531 if (pInstance==fCompressionMonitorHandler) {
532 delete fCompressionMonitorHandler;
533 fCompressionMonitorHandler=NULL;
534 }
535
626bfcc1 536 return 0;
537}
538
539AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
540{
541 // see header file for class documentation
542}
543
544AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
545{
546 // see header file for class documentation
547}
548
549int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
550{
551 // see header file for class documentation
552 if (!pData) return -EINVAL;
553 AliHLTComponentDataType dt=kAliHLTVoidDataType;
554 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
555 int iResult=pData->GetDataBlockDescription(dt, spec);
556 if (iResult>=0) {
557 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
558 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
559 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
560 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
561 iResult=768;
562 if (part>1) iResult+=72+4*slice+(part-2);
563 else iResult+=2*slice+part;
564 } else {
565 HLTError("handler can not process merged data from multiple ddls:"
566 " min slice %d, max slice %d, min part %d, max part %d",
567 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
568 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
569 iResult=-EBADMSG;
570 }
571 }
572 return iResult;
573}