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