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