]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCAgent.cxx
adding configuration TPC-compression-monitoring; removing mode parameter for TPC...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCAgent.cxx
1 // $Id$
2
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 //**************************************************************************
18
19 //  @file   AliHLTTPCAgent.cxx
20 //  @author Matthias Richter
21 //  @date   
22 //  @brief  Agent of the libAliHLTTPC library
23 //  @note   
24
25 #include "AliHLTTPCAgent.h"
26 #include "AliHLTTPCDefinitions.h"
27 #include "AliHLTOUT.h"
28 #include "AliHLTOUTHandlerChain.h"
29 #include "AliRunLoader.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBEntry.h"
32 #include "AliTPCParam.h"
33
34 /** global instance for agent registration */
35 AliHLTTPCAgent gAliHLTTPCAgent;
36
37 // component headers
38 #include "AliHLTTPCCompModelInflaterComponent.h"
39 #include "AliHLTTPCCompModelDeflaterComponent.h"
40 #include "AliHLTTPCCompModelDeconverterComponent.h"
41 #include "AliHLTTPCCompModelConverterComponent.h"
42 #include "AliHLTTPCCompDumpComponent.h"
43 //#include "AliHLTTPCCalibCEComponent.h"
44 //#include "AliHLTTPCCalibPulserComponent.h"
45 //#include "AliHLTTPCCalibPedestalComponent.h"
46 #include "AliHLTTPCCAInputDataCompressorComponent.h"
47 #include "AliHLTTPCCATrackerComponent.h"
48 #include "AliHLTTPCCATrackerOutputConverter.h"
49 #include "AliHLTTPCTrackMCMarkerComponent.h"
50 #include "AliHLTTPCCAGlobalMergerComponent.h"
51 #include "AliHLTTPCdEdxComponent.h"
52 #include "AliHLTTPCdEdxMonitoringComponent.h"
53 #include "AliHLTTPCGlobalMergerComponent.h"
54 #include "AliHLTTPCSliceTrackerComponent.h"
55 #include "AliHLTTPCClusterFinderComponent.h"
56 #include "AliHLTTPCRawDataUnpackerComponent.h"
57 #include "AliHLTTPCDigitPublisherComponent.h"
58 #include "AliHLTTPCDigitDumpComponent.h"
59 #include "AliHLTTPCClusterDumpComponent.h"
60 #include "AliHLTTPCEsdWriterComponent.h"
61 #include "AliHLTTPCOfflineClustererComponent.h"
62 #include "AliHLTTPCOfflineTrackerComponent.h"
63 #include "AliHLTTPCOfflineTrackerCalibComponent.h"
64 #include "AliHLTTPCOfflineCalibrationComponent.h" // to be added to the calibration library agent
65 #include "AliHLTTPCClusterHistoComponent.h"
66 #include "AliHLTTPCHistogramHandlerComponent.h"
67 //#include "AliHLTTPCCalibTracksComponent.h"
68 #include "AliHLTTPCTrackHistoComponent.h"
69 #include "AliHLTTPCTrackDumpComponent.h"
70 #include "AliHLTTPCHWCFDataReverterComponent.h"
71 #include "AliHLTTPCHWClusterTransformComponent.h"
72 #include "AliHLTTPCCFComparisonComponent.h"
73 // #include "AliHLTTPCCalibSeedMakerComponent.h"
74 // #include "AliHLTTPCCalibTimeComponent.h"
75 // #include "AliHLTTPCCalibTimeGainComponent.h"
76 // #include "AliHLTTPCCalibrationComponent.h"
77 #include "AliHLTTPCDataCheckerComponent.h"
78 #include "AliHLTTPCHWCFEmulatorComponent.h"
79 #include "AliHLTTPCHWCFConsistencyControlComponent.h"
80 #include "AliHLTTPCDataCompressionComponent.h"
81 #include "AliHLTTPCDataCompressionMonitorComponent.h"
82
83 /** ROOT macro for the implementation of ROOT specific class methods */
84 ClassImp(AliHLTTPCAgent)
85
86 AliHLTTPCAgent::AliHLTTPCAgent()
87   : AliHLTModuleAgent("TPC")
88   , fRawDataHandler(NULL)
89   , fTracksegsDataHandler(NULL)
90   , fClustersDataHandler(NULL)
91 {
92   // see header file for class documentation
93   // or
94   // refer to README to build package
95   // or
96   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
97 }
98
99 AliHLTTPCAgent::~AliHLTTPCAgent()
100 {
101   // see header file for class documentation
102 }
103
104 int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
105                                          AliRawReader* rawReader,
106                                          AliRunLoader* runloader) const
107 {
108   // see header file for class documentation
109   if (handler) {
110
111     // This the tracking configuration for the full TPC
112     // - 216 clusterfinders (1 per partition)
113     // - 36 slice trackers
114     // - one global merger
115     // - the esd converter
116     // The ESD is shipped embedded into a TTree
117     int iMinSlice=0; 
118     int iMaxSlice=35;
119     int iMinPart=0;
120     int iMaxPart=5;
121     TString arg;
122     TString mergerInput;
123     TString sinkRawData;
124     TString sinkClusterInput;
125     TString sinkHWClusterInput;
126     TString dEdXInput;
127     TString compressorInput;
128     for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
129       TString trackerInput;
130       for (int part=iMinPart; part<=iMaxPart; part++) {
131         TString publisher, cf;
132
133         // digit publisher components
134         publisher.Form("TPC-DP_%02d_%d", slice, part);
135         if (rawReader || !runloader) {
136           // AliSimulation: use the AliRawReaderPublisher if the raw reader is available
137           // Alireconstruction: indicated by runloader==NULL, run always on raw data
138           int ddlno=768;
139           if (part>1) ddlno+=72+4*slice+(part-2);
140           else ddlno+=2*slice+part;
141           arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC '  -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
142           handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
143         } else {
144           arg.Form("-slice %d -partition %d", slice, part);
145           handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
146         }
147
148         if (sinkRawData.Length()>0) sinkRawData+=" ";
149         sinkRawData+=publisher;
150
151         // cluster finder components
152         cf.Form("TPC-CF_%02d_%d", slice, part);
153         arg="-release-memory -publish-raw";
154         if (!rawReader && runloader) {
155           arg+=" -do-mc";
156           handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), arg.Data());
157         } else {
158           handler->CreateConfiguration(cf.Data(), "TPCClusterFinder32Bit", publisher.Data(),arg.Data());
159         }
160
161         // Hardware CF emulator
162         // soon going to replace the software clusterfinder
163         TString hwcfemu;
164         hwcfemu.Form("TPC-HWCFEmu_%02d_%d", slice, part);
165         handler->CreateConfiguration(hwcfemu.Data(), "TPCHWClusterFinderEmulator", publisher.Data(), "-do-mc 1");
166         if (compressorInput.Length()>0) compressorInput+=" ";
167         compressorInput+=hwcfemu;
168
169         TString hwcf;
170         hwcf.Form("TPC-HWCF_%02d_%d", slice, part);
171         handler->CreateConfiguration(hwcf.Data(), "TPCHWClusterTransform",hwcfemu.Data(), "-publish-raw");
172
173         if (trackerInput.Length()>0) trackerInput+=" ";
174         trackerInput+=hwcf;
175         if (dEdXInput.Length()>0) dEdXInput+=" ";
176         dEdXInput+=hwcf;
177         if (sinkClusterInput.Length()>0) sinkClusterInput+=" ";
178         sinkClusterInput+=cf;
179         if (sinkHWClusterInput.Length()>0) sinkHWClusterInput+=" ";
180         sinkHWClusterInput+=hwcf;
181       }
182       TString tracker;
183       // tracker finder components
184       tracker.Form("TPC-TR_%02d", slice);
185       handler->CreateConfiguration(tracker.Data(), "TPCCATracker", trackerInput.Data(), "");
186
187       if (mergerInput.Length()>0) mergerInput+=" ";
188       mergerInput+=tracker;
189
190     }
191
192     // GlobalMerger component
193     handler->CreateConfiguration("TPC-globalmerger","TPCCAGlobalMerger",mergerInput.Data(),"");
194
195     // dEdx component
196     if (dEdXInput.Length()>0) dEdXInput+=" ";
197     dEdXInput+="TPC-globalmerger";
198
199     handler->CreateConfiguration("TPC-dEdx","TPCdEdx",dEdXInput.Data(),"");
200
201     // compression component
202     if (compressorInput.Length()>0) compressorInput+=" ";
203     compressorInput+="TPC-globalmerger";
204     arg.Form("-deflater-mode 1");
205     handler->CreateConfiguration("TPC-compression", "TPCDataCompressor", compressorInput.Data(), arg.Data());
206     arg+=" -cluster-verification 1";
207     handler->CreateConfiguration("TPC-compression-verification", "TPCDataCompressor", compressorInput.Data(), arg.Data());
208     handler->CreateConfiguration("TPC-compression-huffman-trainer", "TPCDataCompressor", compressorInput.Data(),"-deflater-mode 3");
209     handler->CreateConfiguration("TPC-compression-monitoring", "TPCDataCompressorMonitor", "TPC-compression-verification TPC-hwcfdata","");
210
211     // the esd converter configuration
212     TString converterInput="TPC-globalmerger";
213     if (!rawReader && runloader) {
214       // propagate cluster info to the esd converter in order to fill the MC information
215       handler->CreateConfiguration("TPC-clustermc-info", "BlockFilter"   , sinkHWClusterInput.Data(), "-datatype 'CLMCINFO' 'TPC '");  
216       handler->CreateConfiguration("TPC-mcTrackMarker","TPCTrackMCMarker","TPC-globalmerger TPC-clustermc-info","" );
217       converterInput+=" ";
218       converterInput+="TPC-mcTrackMarker";
219     }
220     handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter"   , converterInput.Data(), "");
221
222     // cluster dump collection
223     handler->CreateConfiguration("TPC-clusters", "BlockFilter"   , sinkClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
224     handler->CreateConfiguration("TPC-raw-clusters", "BlockFilter"   , sinkClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
225     handler->CreateConfiguration("TPC-hwclusters", "BlockFilter"   , sinkHWClusterInput.Data(), "-datatype 'CLUSTERS' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
226     handler->CreateConfiguration("TPC-raw-hwclusters", "BlockFilter"   , sinkHWClusterInput.Data(), "-datatype 'CLUSTRAW' 'TPC ' -datatype 'CLMCINFO' 'TPC '");
227
228     // raw data
229     handler->CreateConfiguration("TPC-raw-data", "BlockFilter"   , sinkRawData.Data(), "");
230
231     handler->CreateConfiguration("TPC-hwcfdata", "BlockFilter"   , compressorInput.Data(), "-datatype 'HWCLUST1' 'TPC '");
232
233     /////////////////////////////////////////////////////////////////////////////////////
234     //
235     // dumps on the ALTRO digit level
236     //
237     // selected channel dump
238     arg.Form("-datafile selected-channel.dump -specfmt=_0x%%08x -subdir -blcknofmt= -idfmt=");
239     handler->CreateConfiguration("TPC-selected-altro-digits", "TPCDigitDump", "RCU-channelselect", arg.Data());
240
241     // raw channel dump
242     arg.Form("-datafile channel.dump -specfmt=_0x%%08x -subdir -blcknofmt= -idfmt=");
243     handler->CreateConfiguration("TPC-raw-altro-digits", "TPCDigitDump", "TPC-raw-data", arg.Data());
244
245     /////////////////////////////////////////////////////////////////////////////////////
246     //
247     // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
248     // collects the data blocks, merges the tracks and produces an ESD object
249
250     // publisher component
251     handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher"   , NULL, "");
252
253     // GlobalMerger component
254     handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
255
256     // the esd converter configuration
257     handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
258
259     /////////////////////////////////////////////////////////////////////////////////////
260     //
261     // a kChain HLTOUT configuration for processing of {'TRACKS  ':'TPC '} data blocks
262     // produces an ESD object from the track structure
263
264     // publisher component
265     handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher"   , NULL, "");
266
267     // the esd converter configuration
268     handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
269
270     /////////////////////////////////////////////////////////////////////////////////////
271     //
272     // a kChain HLTOUT configuration for processing of {'CLUSTERS':'TPC '} data blocks
273     // stores the blocks in file HLT.TPC.Clusters.root in HOMER format
274
275     // publisher component
276     handler->CreateConfiguration("TPC-hltout-cluster-publisher", "AliHLTOUTPublisher"   , NULL, "");
277
278     // the HLTOUT component collects the blocks and stores the file
279     handler->CreateConfiguration("TPC-hltout-cluster-dump", "HLTOUT", "TPC-hltout-cluster-publisher", "-digitfile HLT.TPC.Clusters.root -rawout=off -links 2");
280   }
281
282   return 0;
283 }
284
285 const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
286                                                     AliRunLoader* runloader) const
287 {
288   // see header file for class documentation
289   if (runloader) {
290     // reconstruction chains for AliRoot simulation
291     // Note: run loader is only available while running embedded into
292     // AliRoot simulation
293     //if (runloader->GetLoader("TPCLoader") != NULL)
294       //return "TPC-esd-converter TPC-clusters";
295
296     // 2010-10-26 TPC clusters not written to HLTOUT in order to make the simulation
297     // closer to the real data 
298     //return "TPC-clusters";
299   }
300   return NULL;
301 }
302
303 const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
304 {
305   // see header file for class documentation
306
307   // actually, the TPC library has dependencies to Util and RCU
308   // so the two has to be loaded anyhow before we get here
309   //return "libAliHLTUtil.so libAliHLTRCU.so";
310   return "libAliHLTUtil.so";
311 }
312
313 int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
314 {
315   // see header file for class documentation
316   if (!pHandler) return -EINVAL;
317
318 //   pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
319 //   pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
320 //   pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
321   pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
322   pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
323   pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
324   pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
325   pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
326   pHandler->AddComponent(new AliHLTTPCCAInputDataCompressorComponent);
327   pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
328   pHandler->AddComponent(new AliHLTTPCCATrackerOutputConverter);
329   pHandler->AddComponent(new AliHLTTPCCAGlobalMergerComponent);
330   pHandler->AddComponent(new AliHLTTPCTrackMCMarkerComponent);
331   pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
332   pHandler->AddComponent(new AliHLTTPCdEdxComponent);
333   pHandler->AddComponent(new AliHLTTPCdEdxMonitoringComponent);
334   pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
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 AliHLTTPCEsdWriterComponent::AliWriter);
344   pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
345   pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
346   pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
347   pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
348   pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
349   pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
350   pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
351   //pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
352   pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
353   pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
354   pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
355   pHandler->AddComponent(new AliHLTTPCHWClusterTransformComponent);
356   pHandler->AddComponent(new AliHLTTPCCFComparisonComponent);
357 //   pHandler->AddComponent(new AliHLTTPCCalibSeedMakerComponent);
358 //   pHandler->AddComponent(new AliHLTTPCCalibTimeComponent);
359 //   pHandler->AddComponent(new AliHLTTPCCalibTimeGainComponent);
360 //   pHandler->AddComponent(new AliHLTTPCCalibrationComponent);
361   pHandler->AddComponent(new AliHLTTPCDataCheckerComponent);
362   pHandler->AddComponent(new AliHLTTPCHWCFEmulatorComponent);
363 //  pHandler->AddComponent(new AliHLTTPCHWCFConsistencyControlComponent);  //FIXME: Causes crash: https://savannah.cern.ch/bugs/?83677
364   pHandler->AddComponent(new AliHLTTPCDataCompressionComponent);
365   pHandler->AddComponent(new AliHLTTPCDataCompressionMonitorComponent);
366   return 0;
367 }
368
369 int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
370                                           AliHLTUInt32_t spec,
371                                           AliHLTOUTHandlerDesc& desc) const
372 {
373   // see header file for class documentation
374
375   // raw data blocks to be fed into offline reconstruction
376   if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
377     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
378     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
379     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
380         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
381       desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
382       return 1;
383     } else {
384       HLTWarning("handler can not process merged data from multiple ddls:"
385                  " min slice %d, max slice %d, min part %d, max part %d",
386                  slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
387                  part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
388       return 0;
389     }
390   }
391
392   // dump for {'CLUSTERS':'TPC '} blocks stored in a 'digit' file
393   if (dt==AliHLTTPCDefinitions::fgkClustersDataType) {
394       desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
395       return 1;
396   }
397
398   // {'CLUSTRAW':'TPC '}
399   // {'REMCLSCM':'TPC '}
400   // {'CLSTRKCM':'TPC '}
401   // {'REMCLIDS':'TPC '}
402   // {'CLIDSTRK':'TPC '}
403   if (dt==AliHLTTPCDefinitions::RawClustersDataType() ||
404       dt==AliHLTTPCDefinitions::RemainingClustersCompressedDataType() ||
405       dt==AliHLTTPCDefinitions::ClusterTracksCompressedDataType() ||
406       dt==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
407       dt==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
408       desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
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   return NULL;
468 }
469
470 int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
471 {
472   // see header file for class documentation
473   if (pInstance==NULL) return -EINVAL;
474
475   if (pInstance==fRawDataHandler) {
476     delete fRawDataHandler;
477     fRawDataHandler=NULL;
478   }
479
480   if (pInstance==fTracksegsDataHandler) {
481     delete fTracksegsDataHandler;
482     fTracksegsDataHandler=NULL;
483   }
484
485   if (pInstance==fClustersDataHandler) {
486     delete fClustersDataHandler;
487     fClustersDataHandler=NULL;
488   }
489
490   return 0;
491 }
492
493 AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
494 {
495   // see header file for class documentation
496 }
497
498 AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
499 {
500   // see header file for class documentation
501 }
502
503 int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
504 {
505   // see header file for class documentation
506   if (!pData) return -EINVAL;
507   AliHLTComponentDataType dt=kAliHLTVoidDataType;
508   AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
509   int iResult=pData->GetDataBlockDescription(dt, spec);
510   if (iResult>=0) {
511     int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
512     int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
513     if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
514         part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
515       iResult=768;
516       if (part>1) iResult+=72+4*slice+(part-2);
517       else iResult+=2*slice+part;
518     } else {
519       HLTError("handler can not process merged data from multiple ddls:"
520                " min slice %d, max slice %d, min part %d, max part %d",
521                slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
522                part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
523       iResult=-EBADMSG;
524     }
525   }
526   return iResult;
527 }