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