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