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