]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCAgent.cxx
handling of non-std ESD content
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCAgent.cxx
CommitLineData
5578cf60 1// @(#) $Id$
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
19/** @file AliHLTTPCAgent.cxx
20 @author Matthias Richter
21 @date
22 @brief Agent of the libAliHLTTPC library
23*/
24
25#include "AliHLTTPCAgent.h"
26#include "AliHLTConfiguration.h"
626bfcc1 27#include "AliHLTTPCDefinitions.h"
28#include "AliHLTOUT.h"
73449074 29#include "AliHLTOUTHandlerChain.h"
352670bf 30#include "AliRunLoader.h"
5578cf60 31
32/** global instance for agent registration */
33AliHLTTPCAgent gAliHLTTPCAgent;
34
e1440dab 35// component headers
672f8b8c 36#include "AliHLTTPCRunStatisticsProducerComponent.h"
37#include "AliHLTTPCEventStatisticsProducerComponent.h"
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 "AliHLTTPCCATrackerComponent.h"
47#include "AliHLTTPCGlobalMergerComponent.h"
48#include "AliHLTTPCSliceTrackerComponent.h"
49#include "AliHLTTPCVertexFinderComponent.h"
50#include "AliHLTTPCClusterFinderComponent.h"
51#include "AliHLTTPCRawDataUnpackerComponent.h"
52#include "AliHLTTPCDigitPublisherComponent.h"
53#include "AliHLTTPCZeroSuppressionComponent.h"
e1440dab 54#include "AliHLTTPCDigitDumpComponent.h"
0efebbac 55#include "AliHLTTPCClusterDumpComponent.h"
f32b83e1 56#include "AliHLTTPCEsdWriterComponent.h"
1ac82ce6 57#include "AliHLTTPCOfflineClustererComponent.h"
58#include "AliHLTTPCOfflineTrackerComponent.h"
0e442a0a 59#include "AliHLTTPCOfflineTrackerCalibComponent.h"
e642ae99 60#include "AliHLTTPCOfflineCalibrationComponent.h"
0efebbac 61#include "AliHLTTPCClusterHistoComponent.h"
3a3550fa 62#include "AliHLTTPCNoiseMapComponent.h"
63#include "AliHLTTPCHistogramHandlerComponent.h"
64#include "AliHLTTPCCalibTracksComponent.h"
65
e1440dab 66
5578cf60 67/** ROOT macro for the implementation of ROOT specific class methods */
68ClassImp(AliHLTTPCAgent)
69
70AliHLTTPCAgent::AliHLTTPCAgent()
626bfcc1 71 :
72 AliHLTModuleAgent("TPC"),
73 fRawDataHandler(NULL),
73449074 74 fTracksegsDataHandler(NULL)
5578cf60 75{
76 // see header file for class documentation
77 // or
78 // refer to README to build package
79 // or
80 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
81}
82
83AliHLTTPCAgent::~AliHLTTPCAgent()
84{
85 // see header file for class documentation
86}
87
88int AliHLTTPCAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
4fc08fff 89 AliRawReader* rawReader,
298ef463 90 AliRunLoader* /*runloader*/) const
5578cf60 91{
92 // see header file for class documentation
93 if (handler) {
672f8b8c 94
95 // This the tracking configuration for the full TPC
96 // - 216 clusterfinders (1 per partition)
97 // - 36 slice trackers
98 // - one global merger
99 // - the esd converter
100 // The ESD is shipped embedded into a TTree
dfa1592e 101 int iMinSlice=0;
672f8b8c 102 int iMaxSlice=35;
dfa1592e 103 int iMinPart=0;
672f8b8c 104 int iMaxPart=5;
105 TString mergerInput;
dfa1592e 106 for (int slice=iMinSlice; slice<=iMaxSlice; slice++) {
107 TString trackerInput;
108 for (int part=iMinPart; part<=iMaxPart; part++) {
109 TString arg, publisher, cf;
110
111 // digit publisher components
0ba35c53 112 publisher.Form("TPC-DP_%02d_%d", slice, part);
4fc08fff 113 if (!rawReader) {
114 arg.Form("-slice %d -partition %d", slice, part);
115 handler->CreateConfiguration(publisher.Data(), "TPCDigitPublisher", NULL , arg.Data());
116 } else {
117 int ddlno=768;
118 if (part>1) ddlno+=72+4*slice+(part-2);
119 else ddlno+=2*slice+part;
120 arg.Form("-minid %d -datatype 'DDL_RAW ' 'TPC ' -dataspec 0x%02x%02x%02x%02x -silent", ddlno, slice, slice, part, part);
121 handler->CreateConfiguration(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data());
122 }
dfa1592e 123
124 // cluster finder components
0ba35c53 125 cf.Form("TPC-CF_%02d_%d", slice, part);
4fc08fff 126 if (!rawReader) {
127 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderUnpacked", publisher.Data(), "-timebins 446 -sorted");
128 } else {
129 handler->CreateConfiguration(cf.Data(), "TPCClusterFinderDecoder", publisher.Data(), "-timebins 446");
130 }
dfa1592e 131 if (trackerInput.Length()>0) trackerInput+=" ";
132 trackerInput+=cf;
133 }
134 TString tracker;
135 // tracker finder components
0ba35c53 136 tracker.Form("TPC-TR_%02d", slice);
672f8b8c 137 handler->CreateConfiguration(tracker.Data(), "TPCSliceTracker", trackerInput.Data(), "-pp-run -bfield 0.5");
dfa1592e 138
672f8b8c 139 if (mergerInput.Length()>0) mergerInput+=" ";
140 mergerInput+=tracker;
dfa1592e 141
dfa1592e 142 }
5578cf60 143
672f8b8c 144 // GlobalMerger component
0ba35c53 145 handler->CreateConfiguration("TPC-globalmerger","TPCGlobalMerger",mergerInput.Data(),"");
672f8b8c 146
147 // the esd converter configuration
4fc08fff 148 handler->CreateConfiguration("TPC-esd-converter", "TPCEsdConverter" , "TPC-globalmerger", "");
73449074 149
150 /////////////////////////////////////////////////////////////////////////////////////
151 //
152 // a kChain HLTOUT configuration for processing of {'TRAKSEGS':'TPC '} data blocks
153 // collects the data blocks, merges the tracks and produces an ESD object
154
155 // publisher component
156 handler->CreateConfiguration("TPC-hltout-tracksegs-publisher", "AliHLTOUTPublisher" , NULL, "");
157
158 // GlobalMerger component
159 handler->CreateConfiguration("TPC-hltout-tracksegs-merger", "TPCGlobalMerger", "TPC-hltout-tracksegs-publisher", "");
160
161 // the esd converter configuration
162 handler->CreateConfiguration("TPC-hltout-tracksegs-esd-converter", "TPCEsdConverter", "TPC-hltout-tracksegs-merger", "");
163
164 /////////////////////////////////////////////////////////////////////////////////////
165 //
166 // a kChain HLTOUT configuration for processing of {'TRACKS ':'TPC '} data blocks
167 // produces an ESD object from the track structure
168
169 // publisher component
170 handler->CreateConfiguration("TPC-hltout-tracks-publisher", "AliHLTOUTPublisher" , NULL, "");
171
172 // the esd converter configuration
173 handler->CreateConfiguration("TPC-hltout-tracks-esd-converter", "TPCEsdConverter", "TPC-hltout-tracks-publisher", "");
5578cf60 174 }
175 return 0;
176}
177
dee38f1b 178const char* AliHLTTPCAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
ff6648de 179 AliRunLoader* runloader) const
5578cf60 180{
181 // see header file for class documentation
ff6648de 182 if (runloader) {
183 // reconstruction chains for AliRoot simulation
184 // Note: run loader is only available while running embedded into
185 // AliRoot simulation
352670bf 186 if (runloader->GetLoader("TPCLoader") != NULL)
187 return "TPC-esd-converter";
ff6648de 188 }
189 return NULL;
5578cf60 190}
191
192const char* AliHLTTPCAgent::GetRequiredComponentLibraries() const
193{
194 // see header file for class documentation
5ad1e184 195
196 // actually, the TPC library has dependencies to Util and RCU
197 // so the two has to be loaded anyhow before we get here
198 //return "libAliHLTUtil.so libAliHLTRCU.so";
5578cf60 199 return NULL;
200}
f3506ea2 201
e1440dab 202int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
f3506ea2 203{
e1440dab 204 // see header file for class documentation
205 if (!pHandler) return -EINVAL;
672f8b8c 206
207 pHandler->AddComponent(new AliHLTTPCRunStatisticsProducerComponent);
208 pHandler->AddComponent(new AliHLTTPCEventStatisticsProducerComponent);
209 pHandler->AddComponent(new AliHLTTPCCalibCEComponent);
210 pHandler->AddComponent(new AliHLTTPCCalibPulserComponent);
211 pHandler->AddComponent(new AliHLTTPCCalibPedestalComponent);
212 pHandler->AddComponent(new AliHLTTPCCompModelInflaterComponent);
213 pHandler->AddComponent(new AliHLTTPCCompModelDeflaterComponent);
214 pHandler->AddComponent(new AliHLTTPCCompModelDeconverterComponent);
215 pHandler->AddComponent(new AliHLTTPCCompModelConverterComponent);
216 pHandler->AddComponent(new AliHLTTPCCompDumpComponent);
217 pHandler->AddComponent(new AliHLTTPCCATrackerComponent);
218 pHandler->AddComponent(new AliHLTTPCGlobalMergerComponent);
219 pHandler->AddComponent(new AliHLTTPCSliceTrackerComponent);
220 pHandler->AddComponent(new AliHLTTPCVertexFinderComponent);
221 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderPacked));
222 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderUnpacked));
223 pHandler->AddComponent(new AliHLTTPCClusterFinderComponent(AliHLTTPCClusterFinderComponent::kClusterFinderDecoder));
224 pHandler->AddComponent(new AliHLTTPCRawDataUnpackerComponent);
225 pHandler->AddComponent(new AliHLTTPCDigitPublisherComponent);
226 pHandler->AddComponent(new AliHLTTPCZeroSuppressionComponent);
e1440dab 227 pHandler->AddComponent(new AliHLTTPCDigitDumpComponent);
0efebbac 228 pHandler->AddComponent(new AliHLTTPCClusterDumpComponent);
f32b83e1 229 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliWriter);
230 pHandler->AddComponent(new AliHLTTPCEsdWriterComponent::AliConverter);
1ac82ce6 231 pHandler->AddComponent(new AliHLTTPCOfflineClustererComponent);
232 pHandler->AddComponent(new AliHLTTPCOfflineTrackerComponent);
0e442a0a 233 pHandler->AddComponent(new AliHLTTPCOfflineTrackerCalibComponent);
e642ae99 234 pHandler->AddComponent(new AliHLTTPCOfflineCalibrationComponent);
0efebbac 235 pHandler->AddComponent(new AliHLTTPCClusterHistoComponent);
3a3550fa 236 pHandler->AddComponent(new AliHLTTPCNoiseMapComponent);
237 pHandler->AddComponent(new AliHLTTPCHistogramHandlerComponent);
238 pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
239
f3506ea2 240 return 0;
241}
626bfcc1 242
243int AliHLTTPCAgent::GetHandlerDescription(AliHLTComponentDataType dt,
244 AliHLTUInt32_t spec,
245 AliHLTOUTHandlerDesc& desc) const
246{
247 // see header file for class documentation
73449074 248
249 // raw data blocks to be fed into offline reconstruction
626bfcc1 250 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
251 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
252 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
253 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
254 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
255 desc=AliHLTOUTHandlerDesc(kRawReader, dt, GetModuleId());
256 return 1;
257 } else {
258 HLTWarning("handler can not process merged data from multiple ddls:"
259 " min slice %d, max slice %d, min part %d, max part %d",
260 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
261 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
262 return 0;
263 }
264 }
73449074 265
266 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
267 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
268 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
269 return 1;
270 }
271
272 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
273 // there is only one data block
274 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
275 desc=AliHLTOUTHandlerDesc(kChain, dt, GetModuleId());
276 return 1;
277 }
626bfcc1 278 return 0;
279}
280
281AliHLTOUTHandler* AliHLTTPCAgent::GetOutputHandler(AliHLTComponentDataType dt,
b0914d2e 282 AliHLTUInt32_t /*spec*/)
626bfcc1 283{
284 // see header file for class documentation
73449074 285
286 // raw data blocks to be fed into offline reconstruction
626bfcc1 287 if (dt==(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC)) {
288 if (!fRawDataHandler) {
289 fRawDataHandler=new AliHLTTPCAgent::AliHLTTPCRawDataHandler;
290 }
626bfcc1 291 return fRawDataHandler;
292 }
73449074 293
294 // afterburner for {'TRAKSEGS':'TPC '} blocks to be converted to ESD format
295 // in a kChain HLTOUT handler
296 if (dt==AliHLTTPCDefinitions::fgkTrackSegmentsDataType) {
297 if (fTracksegsDataHandler==NULL)
298 fTracksegsDataHandler=new AliHLTOUTHandlerChain("chains=TPC-hltout-tracksegs-esd-converter");
299 return fTracksegsDataHandler;
300 }
301
302 // afterburner for {'TRACKS ':'TPC '} block to be converted to ESD format
303 // there is only one data block
304 if (dt==AliHLTTPCDefinitions::fgkTracksDataType) {
305 return new AliHLTOUTHandlerChain("chains=TPC-hltout-tracks-esd-converter");
306 }
307
626bfcc1 308 return NULL;
309}
310
311int AliHLTTPCAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
312{
313 // see header file for class documentation
314 if (pInstance==NULL) return -EINVAL;
315
316 if (pInstance==fRawDataHandler) {
73449074 317 delete fRawDataHandler;
318 fRawDataHandler=NULL;
319 }
320
321 if (pInstance==fTracksegsDataHandler) {
322 delete fTracksegsDataHandler;
323 fTracksegsDataHandler=NULL;
626bfcc1 324 }
325 return 0;
326}
327
328AliHLTTPCAgent::AliHLTTPCRawDataHandler::AliHLTTPCRawDataHandler()
329{
330 // see header file for class documentation
331}
332
333AliHLTTPCAgent::AliHLTTPCRawDataHandler::~AliHLTTPCRawDataHandler()
334{
335 // see header file for class documentation
336}
337
338int AliHLTTPCAgent::AliHLTTPCRawDataHandler::ProcessData(AliHLTOUT* pData)
339{
340 // see header file for class documentation
341 if (!pData) return -EINVAL;
342 AliHLTComponentDataType dt=kAliHLTVoidDataType;
343 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
344 int iResult=pData->GetDataBlockDescription(dt, spec);
345 if (iResult>=0) {
346 int slice=AliHLTTPCDefinitions::GetMinSliceNr(spec);
347 int part=AliHLTTPCDefinitions::GetMinPatchNr(spec);
348 if (slice==AliHLTTPCDefinitions::GetMaxSliceNr(spec) &&
349 part==AliHLTTPCDefinitions::GetMaxPatchNr(spec)) {
350 iResult=768;
351 if (part>1) iResult+=72+4*slice+(part-2);
352 else iResult+=2*slice+part;
353 } else {
354 HLTError("handler can not process merged data from multiple ddls:"
355 " min slice %d, max slice %d, min part %d, max part %d",
356 slice, AliHLTTPCDefinitions::GetMaxSliceNr(spec),
357 part, AliHLTTPCDefinitions::GetMaxPatchNr(spec));
358 iResult=-EBADMSG;
359 }
360 }
361 return iResult;
362}